I try to encode the × character in a SJIS encoded file… but it doesnt succeed.
I do something like:
string strJapaneseCross = new string('\uC397',1);
StringBuilder sb = new StringBuilder();
sb.AppendLine(strJapaneseCross);
using (StreamWriter sw = new StreamWriter(Path.Combine(filesPath, "MyInfo.txt"), false, Encoding.GetEncoding(932)))
{
sw.Write(sb.ToString());
}
The resulting file is not encoded well, instead of 0x817E in the file (corresponding to × in SJIS) I have 0x3F, which stands for ?
There doesnt seem to be any problem with other japanese character I encode. What I am doing wrong ?
Any help appreciated.
\u escape codes work with the Unicode code points, not the UTF-8 encoding of them. Hence, you’re actually asking to get U+C397 converted, and that is a completely different character – specifically 쎗, a Korean character.
The actual Unicode code point of × is U+00D7, so you want to write: