Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 (\r\n is printed, not as CRLF 10 13 control character).

I know that I could work around this by re-replacing \r\n (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.

like image 832
Alex Avatar asked May 31 '09 02:05

Alex


People also ask

How do you insert a line break in resources?

Use Shift + Enter to insert a new line.

What is carriage return and line feed in C #?

In most C compilers, including ours, the newline escape sequence '\n' yields an ASCII line feed character. The C escape sequence for a carriage return is '\r'.

How do I add a new line in Resx?

Answers. You can also use Shift + Enter in the resource editor...

How do you check carriage return line feed?

Open any text file and click on the pilcrow (¶) button. Notepad++ will show all of the characters with newline characters in either the CR and LF format. If it is a Windows EOL encoded file, the newline characters of CR LF will appear (\r\n). If the file is UNIX or Mac EOL encoded, then it will only show LF (\n).


1 Answers

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> 
like image 104
shahkalpesh Avatar answered Oct 16 '22 12:10

shahkalpesh