Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
816 views
in Technique[技术] by (71.8m points)

newline - Carriage Return/Line Feed in .Net Resource File (App_GlobalResources)

I'm keeping several texts in an App_GlobalResources.resx file.

The texts have to be multi-line and I need to have them contain line feeds. However, when I read the contents, all line feeds are gone ( is printed, not as CRLF 10 13 control character).

I know that I could work around this by re-replacing (or anything else for that matter) back to CRLF when I read the contents, but I wondered why these clearly text-targeted resx files ignore control characters - and CRLF is kind of important - and if anybody knows if there's a setting or something that would enable this to work naturally.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I used VB.NET Express Edition to test this.

In the resource editor (where you can specify the name of the resource and string content) put the string content separated by Shift+Enter.

Lets say you want to type in

hello  
world

Type "hello" followed by Shift+Enter and "world".

If you look at the Resources.Resx file (which is an xml file), you can see that it creates a node with the attribute xml:space="preserve".

2nd option

Also, you can edit the Resources.resx manually and modify the content to be under CDATA section.

Assume that you have the string named "example". Search for it in Resources.resx and change the content to have CDATA section inside it as against having a simple value.

e.g.

<data name="example">
<![CDATA[
hello
world
1
2   3
4
]]>  </data>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...