Results 1 to 13 of 13

Thread: [RESOLVED] Including Russian Cyrillic characters in VB-code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    245

    Resolved [RESOLVED] Including Russian Cyrillic characters in VB-code

    Hi,

    My app supports dynamic switching between various languages. All translated texts are available through external language files, that are loaded when the specific language is selected.

    The welcome screen that is displayed the first time that the app is started allows the initial selection of the language (as part of various settings). As soon as the user selects a language, all texts/controls in the dialog are displayed in the selected language. To make this happen instantly, the texts on the dialog (5 strings for each available language) are included as constants in the code. This works perfectly fine with western languages as English, Dutch, German, Italian, and French.

    Now I’m trying to include Russian with the Cyrillic character set. Loading the texts from a file and the applying to all controls works fine, obviously with all the required settings of fonts and character sets for each control, but I can’t figure out how to include the welcome-screen strings as constants in the VB-code.

    Is this possible at all? If so, any suggestions on how to do that?

    Thanks in advance for your help!

    Regards,
    Erwin

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Including Russian Cyrillic characters in VB-code

    Quote Originally Posted by Erwin69 View Post
    Is this possible at all? If so, any suggestions on how to do that?
    Store the welcome screen text as string resources instead of string constants.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    245

    Re: Including Russian Cyrillic characters in VB-code

    Hi Bonnie,

    Thanks for pointing me in the right direction. Unfortunately, it doesn't work yet though...

    As the VB6 resource editor doesn't allow me to copy/paste the Russian texts (all characters change into ?) I decided to go the "external" route: I created a stringtable in a resource file with Notepad. Saved it in Unicode format with extension rc. Then compiled it with RC.EXE, and added it to my project.

    Now when I assign the texts using the LoadResString function, I still get all questionmarks. The font/charmap settings for the controls are correct, as it displays Russian characters when they're loaded from a text-file.

    What am I missing? Any suggestions would be greatly appreciated!

    Thanks,
    Erwin

  4. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    18

    Re: Including Russian Cyrillic characters in VB-code

    strString = ChrW(decimal value) & ChrW(decimal value) & ChrW(decimal value) & ChrW(decimal value) & ChrW(decimal value) etcetc

    My favorite function, too, it seems.

    http://unicode-table.com/en/, search for the characters you want then use the HTML number.

  5. #5
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Including Russian Cyrillic characters in VB-code

    Have you considered using Unicode aware controls?
    That way you won`t have to worry about Font/CharSet.
    And your Unicode Cyrillic resource file should work just fine.
    See:
    http://www.vbforums.com/showthread.p...=1#post4277565

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Including Russian Cyrillic characters in VB-code

    There is an alternative. I hesitate to mention it because it is quite a hack but it does work for the most part.

    If you take some Russian text in Unicode, then translate this to ANSI using the correct Russion codepage value (1251), then take that ANSI and translate it back to "Unicode" this time using the IDE's codepage...

    .. you get text that can be pasted into VB6 as a String literal.

    This allows you to use something on the order of:

    Code:
    Private Sub lstLanguage_Click()
        With lblPain
            .Font.Charset = Choose(lstLanguage.ListIndex + 1, _
                                   ANSI_CHARSET, _
                                   ANSI_CHARSET, _
                                   RUSSIAN_CHARSET)
            .Caption = Choose(lstLanguage.ListIndex + 1, _
                              "My butt hurts.", _
                              "Mes maux de bout.", _
                              "Ìîé æèâîò áîëèò.")
        End With
    End Sub
    Name:  sshot1.png
Views: 14387
Size:  12.1 KB



    Of course the trick is running the text through that set of translations. For that you can cobble together a translator program as in my AnsiWarp utility (included in the attached archive).

    You need a Unicode textbox of some sort, so here I just used the standard InkEdit control that is included in Windows from Vista forward. If you are stuck on XP yet, this should also still be available as an XP add-on from Microsoft, at least in the crippled inkless form.

    Or you could substitute some other Unicode-aware textbox alternative.

    Name:  sshot2.png
Views: 14464
Size:  15.0 KB



    Before I forget, this table may be useful:

    INFO: Table of Charset Name, Charset Value, and Code Page Number
    Attached Files Attached Files
    Last edited by dilettante; Dec 9th, 2013 at 05:30 PM.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    245

    Re: Including Russian Cyrillic characters in VB-code

    Using Unicode aware controls is the plan for the next big update of the application. So your link above is greatly appreciated!

    The app currently supports on-the-fly switching between English, French, German, Italian and Dutch. Russian is the first step into non-western languages. The translations for each language are in an external file, to allow language updates to be done without requiring a recompile of the software. The welcome screen, displayed only at first startup, is an exception. The translations (effectively 5 labels) are included in the code. This is where my problems started.

    The local Russian team is doing the translations, and have sent me a unicode-textfile with the 5 lines for the welcome screen. If I do a simple load using "Open For Input", and assign the texts to the labels, they display correctly. If I copy them from Notepad and paste them in the VB IDE they're all changed into ?????. Hence the route through the resource file. The issue is that the file compiles well, yet doesn't display the Cyrillic characters. So I was wondering if I should be using something else than the LoadResString function to get the texts out of the resource file correctly.

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Including Russian Cyrillic characters in VB-code

    Oops, I thought the question was:

    Quote Originally Posted by Erwin69 View Post
    Loading the texts from a file and the applying to all controls works fine, obviously with all the required settings of fonts and character sets for each control, but I can’t figure out how to include the welcome-screen strings as constants in the VB-code.

    Is this possible at all? If so, any suggestions on how to do that?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    245

    Re: Including Russian Cyrillic characters in VB-code

    Thanks for the little "hack" dilettante! That worked perfectly fine for the handful of words that I'm dealing with in this case. I can now wrap this up as a "beta 1" so that the guys can start testing their translations, buying myself some time to investigate the unicode controls to see if I may implement those even quicker than originally scheduled.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    245

    Re: Including Russian Cyrillic characters in VB-code

    I guess we were typing replies around the same time...

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Including Russian Cyrillic characters in VB-code

    It's always good to have time to investigate long-term alternatives.

  12. #12
    New Member
    Join Date
    Mar 2018
    Posts
    1

    Re: Including Russian Cyrillic characters in VB-code

    Quote Originally Posted by dilettante View Post
    It's always good to have time to investigate long-term alternatives.
    My problem was that when I pasted Russian or Japanese characters to Microsoft Visual Basic 6 Resource Editor when creating a resource (.RES) file, the characters would appear as question marks (?) both in Resource Editor and when I displayed them on a computer with Russian or Japanese locale, respectively, using the resource DLL that I build from the RES file through MSVB6. However, if I added the characters to the resource file by pasting them into Resource Hacker <http://www.angusj.com/resourcehacker>, the characters still would display as question marks in MSVB6 Resource Editor, but would display correctly on a computer with appropriate locale after I built the resource DLLs through MSVB6.

  13. #13
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: [RESOLVED] Including Russian Cyrillic characters in VB-code

    by pasting them into Resource Hacker
    There is a much better way.
    Just create a resource file with Notepad and save as Unicode (Ex: UnicodeStrings.rc).
    Compile with Rc.exe which should be in folder C:\Program Files (x86)\Microsoft Visual Studio\VB98\Wizards\RC.EXE
    Then you can use LoadResString in Vb6 and it will load strings as Unicode.
    You must have a Unicode control though to display them.

    Typical Batch file to build resource:
    "C:\Program Files (x86)\Microsoft Visual Studio\VB98\Wizards\RC.EXE" UnicodeStrings.rc
    Pause

    but would display correctly on a computer with appropriate locale
    If you use Unicode controls it is not required to set locale, it works with all Locales.
    If you plan on making a multilanguage app you need Unicode controls so that you don't need to fiddle with Locales.

    Here is a sample of UnicodeStrings.rc:
    Code:
    STRINGTABLE
    {
    // UTF16 - Unicode
    90,    "ARA: مـرحبــاً"
    91,    "CHS: 欢迎"
    92,    "CHT: 歡迎"
    93,    "ENG: Welcome"
    94,    "GEO: სასურველი"
    95,    "GRK: Καλώς ήλθατε"
    96,    "HEB: ברוכים הבאים"           
    97,    "HIN: रवागत"
    98,    "JPN: ようこそ"
    99,    "KOR: 여보세요"
    100,    "PUN: ਜੀ ਆਇਆਂ ਨੂੰ"
    101,    "PTB: Bem-vindo"
    102,    "RUS: Добро пожаловать"
    103,    "TAM: அங்கிகரி"
    104,    "THA: การต้อนรับ"
    105,    "URD: स्वागत"
    106,    "VIE: tính từ"
    107,    "ARM: ԱԲԳԴԵԶԷԸԹ"
    108,    "GER: Umlaute ÄÏÖ"
    109,    "KAZ: Қош келдіңіз"
    110,    "MMR: ြကိုဆိုြခင်း။"
    111,    "LAO: ຍິນດີຕ້ອນຮັບ"
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width