C# How to convert a string from English to Japanese ?
-
Hello, I no really nothing about unicode. So I am trying to convert a string that starts out in English and convert it to Japanese. This is what I am doing, but I have no idea what to do and nothing is coming out as Japanese. I tried looking on the internet and the best thing I found was this. http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx But I still can't get it to convert the string. This is what I have for code written so far. Please help. I would expect "This is a Test" to convert to Japanese but it does not. string TestString = "This is a Test"; Encoding ascii = Encoding.GetEncoding(932); Encoding japanese = Encoding.GetEncoding(20127); byte[] unicodeBytes = ascii.GetBytes(TestString); byte[] JapaneseBytes = Encoding.Convert(ascii, japanese, unicodeBytes); char[] JapaneseChars = new char[japanese.GetCharCount(JapaneseBytes, 0, JapaneseBytes.Length)]; japanese.GetChars(JapaneseBytes, 0, JapaneseBytes.Length, JapaneseChars, 0); string JapaneseString = new string(JapaneseChars); string test = System.Text.Encoding.GetEncoding(932).GetString(JapaneseBytes); I just tried this and the string is still in English. I am just looking at the string in the debugger to see what it looks like and it is still english.....
modified on Friday, September 12, 2008 1:45 PM
-
Hello, I no really nothing about unicode. So I am trying to convert a string that starts out in English and convert it to Japanese. This is what I am doing, but I have no idea what to do and nothing is coming out as Japanese. I tried looking on the internet and the best thing I found was this. http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx But I still can't get it to convert the string. This is what I have for code written so far. Please help. I would expect "This is a Test" to convert to Japanese but it does not. string TestString = "This is a Test"; Encoding ascii = Encoding.GetEncoding(932); Encoding japanese = Encoding.GetEncoding(20127); byte[] unicodeBytes = ascii.GetBytes(TestString); byte[] JapaneseBytes = Encoding.Convert(ascii, japanese, unicodeBytes); char[] JapaneseChars = new char[japanese.GetCharCount(JapaneseBytes, 0, JapaneseBytes.Length)]; japanese.GetChars(JapaneseBytes, 0, JapaneseBytes.Length, JapaneseChars, 0); string JapaneseString = new string(JapaneseChars); string test = System.Text.Encoding.GetEncoding(932).GetString(JapaneseBytes); I just tried this and the string is still in English. I am just looking at the string in the debugger to see what it looks like and it is still english.....
modified on Friday, September 12, 2008 1:45 PM
Are you trying to translate the text in the string? There is no conversion or encoding that can do that for you. A proper translation can only be done by a human. There are some pages on the web where you can get an automatic translation, that is at least usable.
Despite everything, the person most likely to be fooling you next is yourself.
-
Are you trying to translate the text in the string? There is no conversion or encoding that can do that for you. A proper translation can only be done by a human. There are some pages on the web where you can get an automatic translation, that is at least usable.
Despite everything, the person most likely to be fooling you next is yourself.
Well, what I am trying to do is say, a person types in an 'a', I can then take that letter and translate it to the Japanese representation of 'a' or what the japanese representation of the key pressed on the keyboard for for 'a' which I think is key 65.
-
Well, what I am trying to do is say, a person types in an 'a', I can then take that letter and translate it to the Japanese representation of 'a' or what the japanese representation of the key pressed on the keyboard for for 'a' which I think is key 65.
I don't know alot about Japanese, but I don't think the Japanese alphabet can be compared to the Latin (our) alphabet. Japanese and Chinese characters are syllables, no letters. I also think the Japanese alphabet has alot more characters than ours. Edit: People that want to see Japanese characters will need the East-Asian characters to be enabled with their OS. Check this Wikipedia page for more information how to do this (not too hard). http://en.wikipedia.org/wiki/Help:Multilingual_support_(East_Asian)[^]
-
I don't know alot about Japanese, but I don't think the Japanese alphabet can be compared to the Latin (our) alphabet. Japanese and Chinese characters are syllables, no letters. I also think the Japanese alphabet has alot more characters than ours. Edit: People that want to see Japanese characters will need the East-Asian characters to be enabled with their OS. Check this Wikipedia page for more information how to do this (not too hard). http://en.wikipedia.org/wiki/Help:Multilingual_support_(East_Asian)[^]
-
So there is no way to convert a single key press to the Japanese representation of that key press?
No, because there is no relationship between the two languages. Any translation of a letter in English language is an approximation of the CONCEPT of 'a' in Japanese. For instance, there may not be anything like an 'a' key, or whatever key you hit, on a Japanese keyboard. One character can represent a word, like "Song", and may even represent an entire paragraph in English. Last I heard, in Japanese Kanji, there were over 4,000 characters!
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Hello, I no really nothing about unicode. So I am trying to convert a string that starts out in English and convert it to Japanese. This is what I am doing, but I have no idea what to do and nothing is coming out as Japanese. I tried looking on the internet and the best thing I found was this. http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx But I still can't get it to convert the string. This is what I have for code written so far. Please help. I would expect "This is a Test" to convert to Japanese but it does not. string TestString = "This is a Test"; Encoding ascii = Encoding.GetEncoding(932); Encoding japanese = Encoding.GetEncoding(20127); byte[] unicodeBytes = ascii.GetBytes(TestString); byte[] JapaneseBytes = Encoding.Convert(ascii, japanese, unicodeBytes); char[] JapaneseChars = new char[japanese.GetCharCount(JapaneseBytes, 0, JapaneseBytes.Length)]; japanese.GetChars(JapaneseBytes, 0, JapaneseBytes.Length, JapaneseChars, 0); string JapaneseString = new string(JapaneseChars); string test = System.Text.Encoding.GetEncoding(932).GetString(JapaneseBytes); I just tried this and the string is still in English. I am just looking at the string in the debugger to see what it looks like and it is still english.....
modified on Friday, September 12, 2008 1:45 PM
SRogers88 wrote:
I no really nothing about unicode.
I would suggest reading this article[^] for a good introduction.
--Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ "That's what's great about doing user interface work. No matter what you do, people will say that what you did was idiotic." -- Raymond Chen