Link to home
Start Free TrialLog in
Avatar of FergCollins
FergCollins

asked on

VB Application GUI text box will not accept Polish characters

I am working with an application whose user interface is written in VB. If I wish to input a new record that happens to contain Polish chatacters, it will not accept them into the blank field - but instead converts them to 'normal' text for e.g the Polish character that looks like an L with a line through it now becomes a regular L - this is even before anything is committed to the underlying database - so the problem has nothing to do with the database support for Polish character sets.
Is it the case that the Application in question has a default font that does not support Polish characters, and would the vendor need to reconfigure the default font to permit Polish characters to be types into the text boxes?
Thanks,
Fergal
Avatar of VBtom
VBtom

I had a similar problem before.
You can download free polish fonts (polskiestrony, arial CE etc) from http://hermes.umcs.lublin.pl/users/kosmulsk/michal/fonts.htm
Set a polish font for your textbox and your problem should be solved.
Did using a polish font solve your problem? If it doesn't, it should be a unicode to ansi problem. If so, put a comment here, then i can explain you how to get through this.
Avatar of FergCollins

ASKER

Thanks Tom,
I cannot see the VB behind the application I am working with so cannot edit the font type used - however, I have been told that the font type it uses always defaults to the underlying Operating System default font (In this case WinNT).

In this case, the vgafix.fon (a hidden file in the Windows directory) is the default font for the Operating System. It is this file that may need to be replaced with one that can support Polish Text. Have you encountered the vgafix.fon before?

Give me your final thoughts and I will mark the answer you gave me as accepted. Once again, I appreciate your response!
Hi Ferg.

Hope it helped a little, thanks for the points.
If you can't access the vb code, I wish you success, but I'm afraid it will be hard since I guess the app should be patched some way for proper displaying of polish chars.

Vgafix.sys is the font FixedSys, used for the dos-prompt. You could set a different codepage for it (using autoexec.bat or msconfig.exe depending on the windows version) but I'm afraid that will only influence the characters for the dos-prompt and dos-apps, not apps for windows.

The default font for a vb texbox (if the programmer doesn't select another font), is sserife.fon or MS Sans Serif, so if you're sure it's used for the textbox, maybe you could try something with that (PolskieStrony is very similar so probably it might be used to replace this.) But first read further cause the problem might be more complex than this.

I looked back at the app I once made where polish text had to go from excel (which uses unicode) to a VB textbox, I think what I found out might help you or at least make you understand what the problem is about.

Many modern applications use unicode (2 byte-characters, so nrs over 255 possible) for text. Then characters that don't belong to the standard ANSI-set, like the special polish characters, are given numbers over 255.
In unicode, no special font is needed for polish characters, normal Arial or Courier or ... will do (though probably the windows-component "support for central-european languages" should be installed for proper displaying and printing).
In VB it's no problem working with unicode strings (with the functions AscW, ChrW$,  ...).

But, textboxes (and the other intrinsic VB controls) can only display the basic charsets (0..255); actually, I suspect it's DBCS but that makes no difference, this only means a zero byte is added to each character. To display polish characters in a VB textbox, it's necessary to set the font of the textbox to a special CE font, where 55 of the standard ANSI characters have been replaced with special polish characters. For example, character 179 is a "3" in normal fonts but a "l" with a line through in CE fonts. Without a CE font for the textbox, you'll see a 3, with a CE font you'll see the special l.

When the text in the textbox comes from a 1-byte-character source (like a textfile or an access97 database), setting the font for the textbox is enough to solve the problem.

But when the text comes from unicode, there's a second and bigger problem: all characters are converted to 1-byte using the default codepage of the system. So for a windows in english (or some other west-european language), this means that all characters are changed to similar looking standard ansi-characters, which means that all special polish characters will loose their accents, lines and so on. And once they're in the textbox, all unicode information is lost, it's no longer possible to reconstruct the polish character!!! Setting a polish font for the textbox alone won't solve the problem then.
I guess it should be possible to change the default codepage somewhere in the registry, so the conversion of polish characters will work alright (but if this will work, some accent-characters for french, spanish, portuguese, dutch, danish, ... will also be converted to polish chars).
I used the following workaround: I set a CE font for the textbox (to be able to display the polish chars). I found out all numbers of polish chars in CE fonts, and all unicode numbers for the same characters; I give the complete list below, it might be useful for whatever patch you may make are have made for you.Then all strings that had to go from excel (unicode) to the textbox or from the textbox to excel, I passed through two functions I made: UnicodeToCE and CEToUnicode. In this functions, I examined the string char by char, if it contains polish chars, there are replaced to the char with the correct number (1byte- or unicode depending of the direction).

I wish you success. Here's the complete list of polish characters, and 2 small test you can use for testing support of polish characters.
---
Numbers of all polish charcters in CE fonts and unicode:
CE-Font      Unicode            CE-Font      Unicode
140      346            204      282
141      356            207      270
142      381            208      272
143      377            209      323
156      347            210      327
157      357            213      336
158      382            216      344
159      378            217      366
161      711            219      368
162      728            222      354
163      321            224      341
165      260            227      259
170      350            229      314
175      379            230      263
178      731            232      269
179      322            234      281
185      261            236      283
186      351            239      271
188      317            240      273
189      733            241      324
190      318            242      328
191      380            245      337
192      340            248      345
195      258            249      367
197      313            251      369
198      262            254      355
200      268            255      729
202      280
---
Test for polish characters in a VB textbox (1-byte): Make a new VB project with a wide textbox on the form. Set a CE font for the textbox. Paste this code. Then run and you should see the polish characters in the textbox:

Private Sub Form_Load()
Const TestString = "&#338;&#381;&#339;&#382;&#376;!"#%*/239:<=>?@CEFHJLOPQRUXY[^`cefhjlopqruxy{~"
Text1.Text = TestString
End Sub
---
Test for polish characters in unicode.
Copy the following to the clipboard. Start ms word, press Alt-F11, then Ctrl-G, then Ctrl-V. Put the cursor at the end (after "729))" and press enter. Press Alt-F11 again and you should see the polish characters in the word-doc.

Activedocument.Content = ( _
ChrW$(346) & ChrW$(356) & ChrW$(381) & ChrW$(377) & ChrW$(347) & _
ChrW$(357) & ChrW$(382) & ChrW$(378) & ChrW$(711) & ChrW$(728) & _
ChrW$(321) & ChrW$(260) & ChrW$(350) & ChrW$(379) & ChrW$(731) & _
ChrW$(322) & ChrW$(261) & ChrW$(351) & ChrW$(317) & ChrW$(733) & _
ChrW$(318) & ChrW$(380) & ChrW$(340) & ChrW$(258) & ChrW$(313) & _
ChrW$(262) & ChrW$(268) & ChrW$(280) & ChrW$(282) & ChrW$(270) & _
ChrW$(272) & ChrW$(323) & ChrW$(327) & ChrW$(336) & ChrW$(344) & _
ChrW$(366) & ChrW$(368) & ChrW$(354) & ChrW$(341) & ChrW$(259) & _
ChrW$(314) & ChrW$(263) & ChrW$(269) & ChrW$(281) & ChrW$(283) & _
ChrW$(271) & ChrW$(273) & ChrW$(324) & ChrW$(328) & ChrW$(337) & _
ChrW$(345) & ChrW$(367) & ChrW$(369) & ChrW$(355) & ChrW$(729))
ASKER CERTIFIED SOLUTION
Avatar of VBtom
VBtom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial