Displaying characters on a form from another code page

  • Thread starter Thread starter adiel_g
  • Start date Start date
A

adiel_g

I am trying to display some data that I received into a form. The
form is in english. The data is in cyrillic (russian) which uses
codepage 1251. I am trying to change the button text to russian. For
example:

cmdCancel.Text = "Îòìåíèòü"

Those are garbage characters which I dont mind if they are in that
format in the code. But when the actual button is displayed on the
screen, I want the real cyrillic (russian) characters to be
displayed. This will be used to translate all the buttons on the page
to cyrillic (russian). My question is how do I change the form to
show characters in cyrillic (russian) without changing the codepage
for the entire computer?

To get an idea of what I am looking for, I would like to run some type
of command such as:

me.codepage = 1251 ' This command does not exit, just a sample of
what I am looking for.

to display the cyrillic (russian) characters for the entire form...

Thanks Before Hand,
Adiel
 
I am trying to display some data that I received into a form. The
form is in english. The data is in cyrillic (russian) which uses
codepage 1251. I am trying to change the button text to russian. For
example:

cmdCancel.Text = "Îòìåíèòü"

Windows Forms controls are unicode-aware. Read the into a string (take a
look at 'System.Text.Encoding.*') and simply assign it to the control's
'Text' property. Note that youÄll have to select a font which contains
glyphs for the characters you want to display (such as Arial Unicode MS).
 
Arial Unicode MS doesn't come out of the box with Windows. It's part of
Office.
I would rather recommend Microsoft Sans Serif or Tahoma.

Note that in most cases, your best bet is simply not to select any font:
Windows usually does a good job at selecting the right font for you if the
selected one doesn't contain the needed glyphs.

My 2 cents,

Serge.
http://www.apptranslator.com - Translating your app is easier than you think
 
I found out what the problem is. The file they sent me with the
russian characters to use was in "russian ANSI" (not sure if this is
what it is called). So when I opened the file and pasted the
characters in the button I got this:

cmdCancel.Text = "Îòìåíèòü"

Since the originating user that created the file has a different code
page in windows, the characters could not be read properly on my
system. I will have him sent me a file that is unicode format. That
file I should be able to read. Then I can place the characters
directly in the code as explained above:

cmdCancel.Text = "ФЙ" ' <- characters are already in the correct
format, they will display correctly.


I have learn this also:

1. If you are saving characters from another code page in your form
using vs2005, visual studio will automatically show a prompt asking if
you want to change the format of the source code file from ANSI to
UNICODE. (Of course you would answer yes to keep the russian
characters in the correct format in your source code)

Thanks Everyone,

Adiel
 
Back
Top