I use ResourceManager
to localize strings in my web forms application. The application supports en-us
and sv-se
. The strings are fetched correctly from the respective resource files, but when they are displayed, unicode characters come as junk values.
resources.sv-se.restext
...
ContactInfoFormatPrimary={0} (primär)
...
Output
Code that gets the resource:
ResourceManager resourceManager = GetResourceManager(...)
...
text = resourceManager.GetString(resourceId);
I tried debugging the code, and the text returned is {0} (prim�r)
What is causing the resource to decode incorrectly?
UPDATE:
I was able to use the same architecture in a console app and obtain the correct string, is there anything related to application configuration that i need to take care of?
Most likely you are not saving your resource text files (
.txt
,.restext
) asUTF-8
orUTF-16
/Unicode
. See the following paragraph from the MSDN documentation ofResgen.exe
:The easiest way to check the enconding of a text file is to open it in
Notepad
, clickSave as...
in theFile
menu and check what's displayed in theEncoding
drop down in the lower right corner. It should be set toUTF-8
orUnicode
.To fix the encoding just select
UTF-8
orUnicode
in theSave as...
dialog ofNotepad
and hitSave
overwriting the original file.