Skip to content

Text encoding

Stig

Asked Jul 2, 2009, 1:05 AM EDT2 answers
Share
LinkedInX
Could you please be so kind and help me in the following situation:
I am coding a simple text editor program whichwould  convert an UTF-8 text file from one unicode range to another (for example, Devanagari into Latin). I have built a table of character correspondences but I am not sure which method to use on this table. So, the problem is to read the text opened in a child window, change it in accordance with my encoding table and open the result in the second MDI window.

I will be thankful for any advice.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Aaron
    0
    If you mean,Taking one letter and turning it into another,Like say,"A" in english to "la" in spanish.
    I would use a "Switch" statement. Heres a example,

    C#
      string Encode, encoder;
                //Put what your gunna say here,well give output according to input
                Console.Write("PUT INPUT HERE: ");
                Encode = Console.ReadLine();
    
    switch (Encode)
                {           //Input,"a - English to spanish"
                    case "a - English to spanish":
                        encoder = "La";
                        break;
     default:
                        encoder = "What? I couldnt encode that!";
                        break;
                }
                Console.WriteLine();
                Console.WriteLine(encoder);
                Console.WriteLine();
                Console.WriteLine("Press [ENTER] to Exit");
                Console.ReadLine();

    This may not be what you want,and would be loads harder,because you would have to have a Switch for every single word like:     a - English to spanish      a - English to Czech
    But,Hopefully this helps a bit!
    (sorry if you were not looking for console)
    0
  • 0
    Thank you for the suggestion, console is OK for now. What I mean is not a translation from one language into another, but a character conversion between several Unicode ranges, for example, Gujarati -> Devanagari, Devanagari - Greek, etc. Although, as it seems, there is not much difference. I have some conversion tables I used in my Tcl scripts which contain two columns like that:
    u1234 u2345
    u3456 u4567, etc.

    Is there any way to use these tables in a C# realisation? I mean, do I have to create a separate class for every table or the Switch case is the best way to treat them?
    0