By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,584 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,584 IT Pros & Developers. It's quick & easy.

UNICODE support in VB 6.0

P: n/a
I have an established program that I am changing to allow users to select
one of eight languages and have all the label captions change accordingly.
I have no problems with English, French, Dutch, German, Spanish or Italian.
The Polish language is causing me trouble.

From what I have read, VB supports UNICODE, in fact it uses UNICODE
internally, which means that ANY character in pretty much any language
should be readable from a UNICODE encoded text file and displayed correctly.

My text files display correctly in Notepad, Wordpad and MS Word. I have
saved the text files in Notepad because I don't need extraneous formatting
characters imbedded in the text file.

The following example text is read correctly from my file and displays
correctly as captions.

Français
NÄHEN
fintantoché
vänligen
aktivitetsfältet
één

The following Polish text does not display correctly. The "special"
characters are either displayed as weird graphic boxes or are split into two
different letters.

UKLAD ZAGLA
BUDOWANIE "DESKI Z GWOZDZIAMI"
zalaczajac
Jesli Twój

I have scoured the 'net until my eyes started burning trying to find a
solution to this problem.

Here is the code that I use to load the strings from the text file.

===========================================
Public Sub LoadLanguage()

Rem Load the appropriate language file from harddrive
On Error GoTo ErrorHandler ' Enable error-handling routine.

Select Case Language

Case 1
Open App.Path & "\Lang-NPW9bEnglish.ltf" For Input As #1
Case 2
Open App.Path & "\Lang-NPW9bDutch.ltf" For Input As #1
Case 3
Open App.Path & "\Lang-NPW9bFrench.ltf" For Input As #1
Case 4
Open App.Path & "\Lang-NPW9bGerman.ltf" For Input As #1
Case 5
Open App.Path & "\Lang-NPW9bItalian.ltf" For Input As #1
Case 6
Open App.Path & "\Lang-NPW9bSwedish.ltf" For Input As #1
Case 7
Open App.Path & "\Lang-NPW9bSpanish.ltf" For Input As #1
Case 8
Open App.Path & "\Lang-NPW9bPolish.ltf" For Input As #1
End Select

Do While Not EOF(1)
Line Input #1, Text ' read the entire line from file until carriage return
character encountered
x = Val(Left$(Text, 3)) ' read the 3 leftmost characters and use that
number for array
If x > 0 Then ' if line is blank then don't read the line
Phrase(x) = Right$(Text, Len(Text) - 4) 'the phrase becomes the entire
line minus the first four characters (the array number!)
End If
Loop

Close #1
Call Form_Load

Exit Sub ' Exit to avoid handler.

ErrorHandler: ' Error-handling routine.
CR = Chr$(10) & Chr$(13)
Select Case Err.Number ' Evaluate error number.
Case 53
Msg = "The language file could not be found. Please place the" & CR
Msg = Msg & "Lang-NPW9bxxxxx.ltf files in the same folder" & CR
Msg = Msg & " where this program is located and try again."
MsgBox Msg, , "Language File Not Found"
Err.Clear ' Clear Err object fields
End Select

End Sub
================================================== ==

Any help you can provide will be much appreciated.

If you need to see this for yourself, you can download my .exe from

http://members.shaw.ca/kyrawhite/Vis...PW9bLanguages/

Also download the .ltf (language translation files in text format) and put
them in same folder as .exe.

Tom
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"....." <tw*****@shaw.ca> wrote in message
news:g1*********************@news1.calgary.shaw.ca ...

The following Polish text does not display correctly. The "special"
characters are either displayed as weird graphic boxes or are split into two different letters.

UKLAD ZAGLA
BUDOWANIE "DESKI Z GWOZDZIAMI"
zalaczajac
Jesli Twój

I have scoured the 'net until my eyes started burning trying to find a
solution to this problem.


Just out of curiosity... what shows up if you load the text directly into a
richtextbox?
Jul 17 '05 #2

P: n/a

"Raoul Watson" <Wa*****@IntelligenCIA.com> wrote in message
news:E9****************@nwrdny02.gnilink.net...

"....." <tw*****@shaw.ca> wrote in message
news:g1*********************@news1.calgary.shaw.ca ...

The following Polish text does not display correctly. The "special"
characters are either displayed as weird graphic boxes or are split into two
different letters.

UKLAD ZAGLA
BUDOWANIE "DESKI Z GWOZDZIAMI"
zalaczajac
Jesli Twój

I have scoured the 'net until my eyes started burning trying to find a
solution to this problem.


Just out of curiosity... what shows up if you load the text directly into

a richtextbox?


I just tried the richtextbox, same problem. The Polish phrase UKLAD uses
an L character that has an angle slash across the middle. Take a look at
the Polish language file at

http://members.shaw.ca/kyrawhite/Vis...PW9bLanguages/

and see if you can get those special characters to somehow display in VB.

Take a look at the language files (they are plain UNICODE text) and then run
my program to see how messed up the Polish text becomes.

Tom
Jul 17 '05 #3

P: n/a

"....." <tw*****@shaw.ca> wrote in message
news:Ye***********************@news3.calgary.shaw. ca...

Take a look at the language files (they are plain UNICODE text) and then run my program to see how messed up the Polish text becomes.


Well Tom.. VB does not understand the "language" set that the file is
encoded in (MS Word does). I added the langage set 1033 code to the RTF and
it seems to work.

Save the text below into test.rtf and load it using rtf loadfile method,
e.g:

RichTextBox1.LoadFile "test.rtf", rtfRTF

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fmodern \fprq1\fcharset238{\*\fnam
e Courier New;}Courier New CE;}{\f1\froman\fprq1\fcharset128 MS
Mincho;}{\f2\fmodern\fprq1\fcharset0 Courier New;}{\f3\fnil\fcharset0 MS
Sans Serif;}}
\viewkind4\uc1\pard\lang1033\f0\fs20 100 UK\'a3AD MUSTRA \f1
\par \f0 101 UK\'a3AD \'afAGLA
\par \f2 102 ZACZEPIENIA LINEK
\par 103 OLINKOWANIE KASKADOWE
\par 104 OLINKOWANIE KLASYCZNE
\par 105 OBLICZENIA
\par 106 OLINKOWANIE
\par 107 BUDOWA TWOJEGO LATAWCA
\par
\par 120 WPROWADZENIE
\par \f0 121 KROK 1 - POTRZEBNE MATERIA\'a3Y
\par \f2 122 KROK 2 - ROZPOCZYNAMY
\par \f0 123 KROK 3 - CI\'caCIE MUSTRA
\par \f2 124 KROK 4 - SZYCIE PANELI
\par 125 KROK 5 - WYKONANIE ZASZEWEK
\par \f0 126 KROK 6 - SZYCIA KRAW\'caDZI
\par 127 KROK 7 - BUDOWANIE \'84DESKI Z GWO\'8fDZIAMI\rdblquote
\par \f2 128 KROK 8 - ZACZEPIANIE LINIE DO LATAWCA
\par 129 KROK 9 - OLINKOWANIE KASKADOWE
\par \f0 130 KROK 10 - \'a3\'a5CZENIE LINEK - PUNKT Q
\par 131 KROK 11 - PRZYGOTOWANIE R\'a5CZEK
\par 132 KROK 12 - WI\'a5ZANIE LINEK G\'a3\'d3WNYCH
\par 133 KROK 13 - LATAJ\'a5C TWOIM NPW
\par \f2 140 GALERIA
\par 141 TERMINOLOGIA
\par 142 LINKI
\par 143 HISTORIA
\par \f0 150 WPROWAD\'8f WYSOKO\'8c\'c6 PANEL A
\par \f2 151 MAKSIMUM
\par 152 POWIERZCHNIA
\par
\par 160 O NPW9B Vulture
\par 161 NPW9B NASA Parawing Kalkulator wersja 1.0.00
\par 162 Napisany w Visual Basic 6.0
\par \f0 163 5 Wrzesie\'f1 2003
\par \f2 164 Prawa autorskie Tom White (ki*****@shaw.ca)
\par 165 To jest email-ware
\par \f0 166 Wy\'9clij mi e-mail, pisz\'b9c gdzie m\f2 ieszkasz
\par \f0 167 za\'b3\'b9czaj\'b9c zdj\'eacie lub dwa twojego latawca w locie.
\par 168 Podzi\'eakowania dla: Bill Painter (Stany Zjednoczone).
\par \f2 169 Larry Green (Kanada)
\par 170 Jean-Pierre Gleyzes (Francja)
\par 171 Fredrik Lejonklou (Szwecja)
\par 172 Stelios Alex (Grecja)
\par 173 Andy Hook (Wielka Brytania)
\par \f0 174 T\'b3umaczenie z j\'eazyka angielskiego na polski
\par 175 Wiktor \'afuchowski
\par \f2 176
\par 177
\par \f0 178 Je\'9cli potrzebujesz wsparcia w j\'eazyku polskim, skontaktuj
si\'ea t\'b3umaczem
\par 179 Je\'9cli potrzebujesz wsparcia w j\'eazyku angielskim, skontaktuj
si\'ea z aut\f2 orem programu
\par
\par \f0 190 Zbli\'bfa si\'ea Tw\'f3j szef?
\par 191 Je\'9cli Tw\'f3j szef przechodzi obok I chcesz szybko ukry\'e6 ten
program
\par 192 naci\'9cnij jeden z klawiszy funkcyjnych (F1 \'85 F10)
\par \f2 193 Program zamknie swoje okna i
\par \f0 194 zostanie zminimalizowany (do paska zada\'f1).
\par \f2 195 \f0 Dodatkowo program usunie swoj\'b9 ikon\'ea
\par 196 z paska zada\'f1 na 45 sekund.
\par 197 Po tej przerwie program powr\'f3ci do paska zada\'f1,
\par 198 ale zminimalizowany, do czasu klikni\'eacia w ikon\'ea.
\par \f2
\par 200 Plik
\par \f0 201 Wyj\'9ccie
\par \f2 202 Pomoc
\par \f0 203 Je\'9cli Tw\'f3j szef przechodzi obok \'85
\par \f2 204 O programie\f3\fs17
\par }
Jul 17 '05 #4

P: n/a
Thanks for you interest and help with this Raoul.

What application produced the output you sent as a plain text file below -
or did you just hand bomb it?

I did experiment with the RichTextBox (I did not know it existed!). It
does not have a transparent background property, an ability to center text
nor a wordwrap feature so it won't work for my application. The language
files that you have seen so far are going to eventually be about 12 times
larger, so I don't want to directly fool around with embedded codes if at
all possible.

I am sending the english text for translation to people in seven different
countries and I don't want them to have to work on anything but straight
text.

Question - the language set of 1033 that you used in your rtf file
corresponds to English. The Polish set is 1045. I played around with
this and even tried every combination of the StrConv function until I was
blue in the face.

My understanding is the ASCII has characters in the 0 - 127 range and the
ANSI set has charcters 0 - 255. I am guessing that since French, Dutch,
Italian, German, Swedish and Spanish "special" characters all work they must
be located in the lower 255 characters. The Polish "special" characters
must not exist within those first 255 characters, and even though VB 6.0
claims to completely run internally in UNICODE, it does not appear to be
doing so. Maybe there is a restriction in my LINE INPUT statement that
strips the UNICODE information.
Well Tom.. VB does not understand the "language" set that the file is
encoded in (MS Word does). I added the langage set 1033 code to the RTF and it seems to work.

Save the text below into test.rtf and load it using rtf loadfile method,
e.g:

RichTextBox1.LoadFile "test.rtf", rtfRTF

{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fmodern \fprq1\fcharset238{\*\fnam e Courier New;}Courier New CE;}{\f1\froman\fprq1\fcharset128 MS
Mincho;}{\f2\fmodern\fprq1\fcharset0 Courier New;}{\f3\fnil\fcharset0 MS
Sans Serif;}}
\viewkind4\uc1\pard\lang1033\f0\fs20 100 UK\'a3AD MUSTRA \f1
\par \f0 101 UK\'a3AD \'afAGLA
\par \f2 102 ZACZEPIENIA LINEK
\par 103 OLINKOWANIE KASKADOWE
\par 104 OLINKOWANIE KLASYCZNE
\par 105 OBLICZENIA
\par 106 OLINKOWANIE
\par 107 BUDOWA TWOJEGO LATAWCA
\par
\par 120 WPROWADZENIE
\par \f0 121 KROK 1 - POTRZEBNE MATERIA\'a3Y
\par \f2 122 KROK 2 - ROZPOCZYNAMY
\par \f0 123 KROK 3 - CI\'caCIE MUSTRA
\par \f2 124 KROK 4 - SZYCIE PANELI
\par 125 KROK 5 - WYKONANIE ZASZEWEK
\par \f0 126 KROK 6 - SZYCIA KRAW\'caDZI
\par 127 KROK 7 - BUDOWANIE \'84DESKI Z GWO\'8fDZIAMI\rdblquote
\par \f2 128 KROK 8 - ZACZEPIANIE LINIE DO LATAWCA
\par 129 KROK 9 - OLINKOWANIE KASKADOWE
\par \f0 130 KROK 10 - \'a3\'a5CZENIE LINEK - PUNKT Q
\par 131 KROK 11 - PRZYGOTOWANIE R\'a5CZEK
\par 132 KROK 12 - WI\'a5ZANIE LINEK G\'a3\'d3WNYCH
\par 133 KROK 13 - LATAJ\'a5C TWOIM NPW
\par \f2 140 GALERIA
\par 141 TERMINOLOGIA
\par 142 LINKI
\par 143 HISTORIA
\par \f0 150 WPROWAD\'8f WYSOKO\'8c\'c6 PANEL A
\par \f2 151 MAKSIMUM
\par 152 POWIERZCHNIA
\par
\par 160 O NPW9B Vulture
\par 161 NPW9B NASA Parawing Kalkulator wersja 1.0.00
\par 162 Napisany w Visual Basic 6.0
\par \f0 163 5 Wrzesie\'f1 2003
\par \f2 164 Prawa autorskie Tom White (ki*****@shaw.ca)
\par 165 To jest email-ware
\par \f0 166 Wy\'9clij mi e-mail, pisz\'b9c gdzie m\f2 ieszkasz
\par \f0 167 za\'b3\'b9czaj\'b9c zdj\'eacie lub dwa twojego latawca w locie. \par 168 Podzi\'eakowania dla: Bill Painter (Stany Zjednoczone).
\par \f2 169 Larry Green (Kanada)
\par 170 Jean-Pierre Gleyzes (Francja)
\par 171 Fredrik Lejonklou (Szwecja)
\par 172 Stelios Alex (Grecja)
\par 173 Andy Hook (Wielka Brytania)
\par \f0 174 T\'b3umaczenie z j\'eazyka angielskiego na polski
\par 175 Wiktor \'afuchowski
\par \f2 176
\par 177
\par \f0 178 Je\'9cli potrzebujesz wsparcia w j\'eazyku polskim, skontaktuj si\'ea t\'b3umaczem
\par 179 Je\'9cli potrzebujesz wsparcia w j\'eazyku angielskim, skontaktuj
si\'ea z aut\f2 orem programu
\par
\par \f0 190 Zbli\'bfa si\'ea Tw\'f3j szef?
\par 191 Je\'9cli Tw\'f3j szef przechodzi obok I chcesz szybko ukry\'e6 ten program
\par 192 naci\'9cnij jeden z klawiszy funkcyjnych (F1 \'85 F10)
\par \f2 193 Program zamknie swoje okna i
\par \f0 194 zostanie zminimalizowany (do paska zada\'f1).
\par \f2 195 \f0 Dodatkowo program usunie swoj\'b9 ikon\'ea
\par 196 z paska zada\'f1 na 45 sekund.
\par 197 Po tej przerwie program powr\'f3ci do paska zada\'f1,
\par 198 ale zminimalizowany, do czasu klikni\'eacia w ikon\'ea.
\par \f2
\par 200 Plik
\par \f0 201 Wyj\'9ccie
\par \f2 202 Pomoc
\par \f0 203 Je\'9cli Tw\'f3j szef przechodzi obok \'85
\par \f2 204 O programie\f3\fs17
\par }

Jul 17 '05 #5

P: n/a

"....." <tw*****@shaw.ca> wrote in message
news:20***********************@news2.calgary.shaw. ca...
Thanks for you interest and help with this Raoul.

What application produced the output you sent as a plain text file below -
or did you just hand bomb it?

You can try it your self. Just open the Unicode file you have with MS Word.
Then save it as an "RTF" or rich text.
I did experiment with the RichTextBox (I did not know it existed!). It
does not have a transparent background property, an ability to center text
nor a wordwrap feature so it won't work for my application.
Not sure if you played with it. It certainly has auto word wrap, multi font
support (to include ultiple size in one line), pictures (graphics), auto
scroll bars, background color, centering, left justification, right
justification, etc. etc. I suggest you go to components, select MS
Richtextbox control. Create a form, put the box and run it. Just start
typing and look at the properties (scroll bars, etc.). Word actually is an
RTF text box.
Question - the language set of 1033 that you used in your rtf file
corresponds to English. The Polish set is 1045. I played around with
this and even tried every combination of the StrConv function until I was
blue in the face.

My understanding is the ASCII has characters in the 0 - 127 range and the
ANSI set has charcters 0 - 255. I am guessing that since French, Dutch,
Italian, German, Swedish and Spanish "special" characters all work they must be located in the lower 255 characters. The Polish "special" characters
must not exist within those first 255 characters, and even though VB 6.0
claims to completely run internally in UNICODE, it does not appear to be
doing so. Maybe there is a restriction in my LINE INPUT statement that
strips the UNICODE information.


In Unicode, a character set is represented by 2 bytes. For example, ascii
letter "A" is represented as 65 00 (or &h41 &h00). Some characters however
is constructed using two Unicode characters (such is the case of your "L"
with a diagonal line). Although I have been programming for over 24 years, I
never dealt with Unicode to be able to give you an algorithm. So sorry
nothing intelligent from a code point of view. I suggest you try to look at
http://www.planetsourcecode.com/vb, I seem to remember years ago to see a VB
program that converts Unicode.

Good luck and sorry I couldn't be more helpful.
Jul 17 '05 #6

P: n/a
After reading the thread of responses, I got interested in this one, since it
seems like it ought to work. So I hunted around in MSDN library, and guess what?
Here is a quote:

"Visual Basic is based internally on the double-byte Unicode standard. However,
most of the world outside of Visual Basic still uses the single- byte ANSI
model. For this reason, Visual Basic provides two sets of form controls and uses
the ANSI set as the default control. Any strings passed to the ANSI set of form
controls will be converted from their internal Unicode representation to an ANSI
representation and will not display the UNICODE strings correctly.

"To be able to display the UNICODE string on a Visual Basic form, the UNICODE
(Forms 2.0) controls must be used. The following example shows how to use the
Forms 2.0 controls to display UNICODE strings read from a Unicode text file.
Because this behavior requires UNICODE language package support, it currently
supported only in Windows NT.

"Select Components from the Project menu and check Microsoft Forms 2.0 Object
Library. Several new controls are added to the toolbox, including UNICODE
versions of the text box, label, and so forth.
.....

Plus this caveat:

"NOTE: The Forms 2.0 controls used in this article were not designed for use on
Visual Basic forms and have not been formally tested in the environment. This
article documents their use only in this very limited context to work around a
limitation to the Visual Basic Intrinsic controls. Using other features of these
controls on Visual Basic forms is not supported.

Furthermore, Forms 2.0 is part of Microsoft Office and is not redistributable.
Therefore, you cannot distribute Forms 2.0 (fm20.dll) with your application. It
must already be on the target machines. End users who do not already have
fm20.dll may download Microsoft ActiveX Control Pad, which includes fm20.dll,
from the following site:

http://msdn.microsoft.com/workshop/misc/cpad/

For additional information on distributing fm20.dll, please see the following
article in the Microsoft Knowledge Base:
Q224305 INFO: Usage and Redistribution of FM20.DLL [OffDev]
-----

Oh well, at least there is a way... I would take the reference to Win NT to mean
Win 2000 and XP as well.
Steve

"....." <tw*****@shaw.ca> wrote in message
news:g1*********************@news1.calgary.shaw.ca ...
I have an established program that I am changing to allow users to select
one of eight languages and have all the label captions change accordingly.
I have no problems with English, French, Dutch, German, Spanish or Italian.
The Polish language is causing me trouble.

From what I have read, VB supports UNICODE, in fact it uses UNICODE
internally, which means that ANY character in pretty much any language
should be readable from a UNICODE encoded text file and displayed correctly.

My text files display correctly in Notepad, Wordpad and MS Word. I have
saved the text files in Notepad because I don't need extraneous formatting
characters imbedded in the text file.

The following example text is read correctly from my file and displays
correctly as captions.

Français
NÄHEN
fintantoché
vänligen
aktivitetsfältet
één

The following Polish text does not display correctly. The "special"
characters are either displayed as weird graphic boxes or are split into two
different letters.

UKLAD ZAGLA
BUDOWANIE "DESKI Z GWOZDZIAMI"
zalaczajac
Jesli Twój

I have scoured the 'net until my eyes started burning trying to find a
solution to this problem.

Here is the code that I use to load the strings from the text file.

===========================================
Public Sub LoadLanguage()

Rem Load the appropriate language file from harddrive
On Error GoTo ErrorHandler ' Enable error-handling routine.

Select Case Language

Case 1
Open App.Path & "\Lang-NPW9bEnglish.ltf" For Input As #1
Case 2
Open App.Path & "\Lang-NPW9bDutch.ltf" For Input As #1
Case 3
Open App.Path & "\Lang-NPW9bFrench.ltf" For Input As #1
Case 4
Open App.Path & "\Lang-NPW9bGerman.ltf" For Input As #1
Case 5
Open App.Path & "\Lang-NPW9bItalian.ltf" For Input As #1
Case 6
Open App.Path & "\Lang-NPW9bSwedish.ltf" For Input As #1
Case 7
Open App.Path & "\Lang-NPW9bSpanish.ltf" For Input As #1
Case 8
Open App.Path & "\Lang-NPW9bPolish.ltf" For Input As #1
End Select

Do While Not EOF(1)
Line Input #1, Text ' read the entire line from file until carriage return
character encountered
x = Val(Left$(Text, 3)) ' read the 3 leftmost characters and use that
number for array
If x > 0 Then ' if line is blank then don't read the line
Phrase(x) = Right$(Text, Len(Text) - 4) 'the phrase becomes the entire
line minus the first four characters (the array number!)
End If
Loop

Close #1
Call Form_Load

Exit Sub ' Exit to avoid handler.

ErrorHandler: ' Error-handling routine.
CR = Chr$(10) & Chr$(13)
Select Case Err.Number ' Evaluate error number.
Case 53
Msg = "The language file could not be found. Please place the" & CR
Msg = Msg & "Lang-NPW9bxxxxx.ltf files in the same folder" & CR
Msg = Msg & " where this program is located and try again."
MsgBox Msg, , "Language File Not Found"
Err.Clear ' Clear Err object fields
End Select

End Sub
================================================== ==

Any help you can provide will be much appreciated.

If you need to see this for yourself, you can download my .exe from

http://members.shaw.ca/kyrawhite/Vis...PW9bLanguages/

Also download the .ltf (language translation files in text format) and put
them in same folder as .exe.

Tom


Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.