I need to use various Welsh characters in my dialog boxes, in particular vowels with circumflex. When I put the string into a static or edit box with SYS"SetDlgItemText" or read a string from an edit box with SYS"GetDlgItemText", instead of lower-case 'a' with a circumflex over it, I get â and similar for other letters.
I would be grateful for any guidance.
I have enabled Unicode in the BB4W editor and used the appropriate value in VDU 23. I have tried using SYS"WideCharToMultiByte" but the trouble is that I don't really know what I am doing with that, so can't tell whether it isn't working, it isn't what I need, or I am using it wrong.
Thanks.
UTF in dialog boxes
Re: UTF in dialog boxes
In addition to those it will be necessary to use either the WINLIB2U or WINLIB5U library to create the Unicode control(s).
There's a page at the Wiki showing how to call that function.I have tried using SYS"WideCharToMultiByte" but the trouble is that I don't really know what I am doing with that
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: UTF in dialog boxes
Hmmm. Bother. I had forgotten the WinLib2U - I have a feeling you have pointed it out to me before, but it doesn't appear to make any difference.
In my dialogue box I have a check box:
PROC_checkbox(dialog%,"",100,10,40,56,10,0)
into which I wish to insert this string:
categorie$="Ysbryd Glân"
SYS"SetDlgItemText",!dialog%,100,categorie$
Even with WinLib2U the check box still appears with "Ysbryd Glân"
Sorry to be so thick.
In my dialogue box I have a check box:
PROC_checkbox(dialog%,"",100,10,40,56,10,0)
into which I wish to insert this string:
categorie$="Ysbryd Glân"
SYS"SetDlgItemText",!dialog%,100,categorie$
Even with WinLib2U the check box still appears with "Ysbryd Glân"
Sorry to be so thick.
Re: UTF in dialog boxes
Taking a step back, which particular Welsh characters are missing from the ANSI character set? The only vowels with a circumflex which are not available, as far as I know, are Ŷŷ, and Ŵŵ i.e. capital and lowercase Y and W with a circumflex. Are they why you need Unicode?
Re: UTF in dialog boxes
If you don't want to change the text dynamically (and changing the name of a checkbox could be argued to be questionable UI design), this should 'just work', since you're using WINLIB2U to create a Unicode control:
Code: Select all
categorie$="Ysbryd Glân"
PROC_checkbox(dialog%,categorie$,100,10,40,56,10,0)
Code: Select all
categorie$="Ysbryd Glân"
SYS "SetDlgItemText", !dialog%, 100, categorie$
Code: Select all
categorie$="Dŵr Sanctaidd"
SYS "SetDlgItemTextW", !dialog%, 100, FNwide(categorie$)
Code: Select all
DEF FNwide(a$)
LOCAL S%, u$
SYS "MultiByteToWideChar", &FDE9, 0, a$, LEN(a$), 0, 0 TO S%
u$ = STRING$(S%*2, CHR$0)
SYS "MultiByteToWideChar", &FDE9, 0, a$, LEN(a$), u$, S%
= u$ + CHR$0 + CHR$0
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: UTF in dialog boxes
Oh that is brilliant! Thanks a million.
I have a file of hymns in which categories are defined - Praise, Worship, Children, Christmas, and so on. My program creates a dialog box with 40 check boxes, then reads in the file, extracting the categories as it goes. It makes sure there is only one instance of each, sorts the categories into alphabetical order, and then sticks one category in each check box. The user (me) can then quickly select a hymn, see which category it comes under, add a new category, delete the category, etc.
So yes, the putting of the categories into the checkboxes is done dynamically, especially when the user creates a new category.
Just as an experiment, I altered your FNwide slightly as follows:
In other words, I have added the two character zeroes when defining u$ rather than when returning the value. It seems to work but is it likely to cause any problems I'm not smart enough to foresee?
Once again, thank you so much.
I have a file of hymns in which categories are defined - Praise, Worship, Children, Christmas, and so on. My program creates a dialog box with 40 check boxes, then reads in the file, extracting the categories as it goes. It makes sure there is only one instance of each, sorts the categories into alphabetical order, and then sticks one category in each check box. The user (me) can then quickly select a hymn, see which category it comes under, add a new category, delete the category, etc.
So yes, the putting of the categories into the checkboxes is done dynamically, especially when the user creates a new category.
Just as an experiment, I altered your FNwide slightly as follows:
Code: Select all
DEFFNwide(a$):LOCALS%,u$
SYS"MultiByteToWideChar",&FDE9,0,a$,LEN(a$),0,0TOS%
u$=STRING$(S%*2+2,CHR$0)
SYS"MultiByteToWideChar",&FDE9,0,a$,LEN(a$),u$,S%
=u$
Once again, thank you so much.