Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1060

C# resource file with Japanese characters

$
0
0

I am reading some Japanese characters out of a resource file for my UI strings. I manually added them to the resource file. They look ok in the resource file and even if I open the resource file with Notepad++. But when I ready them into my variables, they turn into question marks. I know I need to use UTF8 encoding, but where?

I am also reading strings out of an external file (non-resource) and the UTF8 encoding works just fine there.

My suspicion is that it has something to do with the culture property in the resx file. How do I change it from "neutral" to "Japanese"(or whatever is needed)?

this works (reading from a regular file):

using (StreamReader sr = new StreamReader(inputxliff))        {            data = sr.ReadToEnd();        }        inputxliff.Close();        string filetag = "<file original";        int mycount = (data.Length - data.Replace(filetag, "").Length) / filetag.Length;        string header = getBetween(data, "<?", "<file", true, false);        byte[] bheader = Encoding.UTF8.GetBytes(header);

This does NOT work (reading from resx file, actually it works fine for ENU and DEU but not for JPN):

using (ResXResourceSet resxSet = new ResXResourceSet(mypath +"\\ResourcesJPN.resx"))        {            string instructions = resxSet.GetString("instructions");            byte[] instrBytes = Encoding.UTF8.GetBytes(instructions);            string myinstructions = Encoding.UTF8.GetString(instrBytes);

I'd love any suggestions.


Viewing all articles
Browse latest Browse all 1060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>