Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# How to convert a string from English to Japanese ?

C# How to convert a string from English to Japanese ?

Scheduled Pinned Locked Moved C#
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SRogers88
    wrote on last edited by
    #1

    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

    G M 2 Replies Last reply
    0
    • S SRogers88

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • G Guffa

        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.

        S Offline
        S Offline
        SRogers88
        wrote on last edited by
        #3

        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.

        X 1 Reply Last reply
        0
        • S SRogers88

          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.

          X Offline
          X Offline
          Xargo
          wrote on last edited by
          #4

          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)[^]

          S 1 Reply Last reply
          0
          • X Xargo

            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)[^]

            S Offline
            S Offline
            SRogers88
            wrote on last edited by
            #5

            So there is no way to convert a single key press to the Japanese representation of that key press?

            D 1 Reply Last reply
            0
            • S SRogers88

              So there is no way to convert a single key press to the Japanese representation of that key press?

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • S SRogers88

                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

                M Offline
                M Offline
                Michael Dunn
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups