View previous topic :: View next topic |
Author |
Message |
Ald
Joined: 15 Sep 2005 Posts: 4
|
Posted: Thu Sep 15, 2005 1:25 pm Post subject: Displaying international characters |
|
|
Is it at all possible with DFL?
If not, what would you recomment to output on a form, say, japanese alphabet? |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Thu Sep 15, 2005 1:48 pm Post subject: |
|
|
While I haven't checked the code, DFL worked ok for me trying to output UTF-8 characters (Win2K in English, locale Spanish(Ecuador)). I don't know if this success will repeat using other configurations. |
|
Back to top |
|
|
Ald
Joined: 15 Sep 2005 Posts: 4
|
Posted: Thu Sep 15, 2005 2:06 pm Post subject: |
|
|
I also have no problem displaying UTF-8 and ASCII character; but the textboxes and labels simplay say they won't accept dchars and wchars... |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Thu Sep 15, 2005 11:23 pm Post subject: Re: Displaying international characters |
|
|
Most of DFL supports Unicode and will be supported fully in 1.0. On Win9x/ME, however, the only characters that will be displayed correctly are the ones supported by the current code page. As far as I know, it's the same limitation imposed by Phobos and MSLU. It's otherwise limited by what the font supports.
If you have strings as dchars and wchars, just convert them to chars using std.utf.toUTF8(); the conversion is lossless. |
|
Back to top |
|
|
Ald
Joined: 15 Sep 2005 Posts: 4
|
Posted: Fri Sep 16, 2005 8:58 am Post subject: |
|
|
Unfortunately, it still does not work.
The error message is: "4invalid UTF-8 sequence".
......
table1.readExact(buffer4, 2);
kanaChar[0] = convertByte(buffer4);
toUTF8(display, kanaChar[0]);
.....
kanaDisplay.text = display;
......
I should note that in command prompt, without the DFL, the two lines
writefln(kanaChar);
writefln(display);
printed out two identical characters, then program printed the error.
And before you ask -- RichTextBox won't do either. |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Fri Sep 16, 2005 11:01 am Post subject: |
|
|
Ald wrote: | Unfortunately, it still does not work.
The error message is: "4invalid UTF-8 sequence".
......
table1.readExact(buffer4, 2);
kanaChar[0] = convertByte(buffer4);
toUTF8(display, kanaChar[0]);
.....
kanaDisplay.text = display;
...... |
That version of toUTF8() isn't even documented, but browsing its source I see that it returns the slice it actually wrote to the buffer (first param), so if the resulting UTF-8 doesn't completely fill your display buffer, you could be including some old or init bytes which don't form valid UTF-8.
So my suggestion is to either not use this undocumented version of toUTF8(), or try this:
Code: | table1.readExact(buffer4, 2);
kanaChar[0] = convertByte(buffer4);
char[] s = toUTF8(display, kanaChar[0]);
// ...
kanaDisplay.text = s; |
|
|
Back to top |
|
|
Ald
Joined: 15 Sep 2005 Posts: 4
|
Posted: Fri Sep 16, 2005 11:45 am Post subject: |
|
|
Thanks, the code now comiles and runs without any errors; length of the s string is 3 units. However, it still does not output what I expect to see; it outputs a single question mark in a RichTextBox.
This evening I have tried all the possible font combination. The charset has to be in ubyte, rather than in a string; I have tried all 256 of them for Bitstream Cyberfont and MS Gothic, yet nothing worked, for japanese characters occupy place from x3090 to x30ff in unicode table... |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Mon Sep 19, 2005 1:21 pm Post subject: |
|
|
Ald wrote: | This evening I have tried all the possible font combination. The charset has to be in ubyte, rather than in a string; I have tried all 256 of them for Bitstream Cyberfont and MS Gothic, yet nothing worked, for japanese characters occupy place from x3090 to x30ff in unicode table... |
I'm not sure about this. Perhaps you need to use this overload of the Font constructor:
Code: | this(char[] name, float emSize, FontStyle style, GraphicsUnit unit, ubyte gdiCharSet) |
and use one of the following values for gdiCharSet:
Code: | SHIFTJIS_CHARSET
HANGEUL_CHARSET
GB2312_CHARSET
CHINESEBIG5_CHARSET
JOHAB_CHARSET
HEBREW_CHARSET
ARABIC_CHARSET
GREEK_CHARSET
TURKISH_CHARSET
VIETNAMESE_CHARSET
THAI_CHARSET
EASTEUROPE_CHARSET
RUSSIAN_CHARSET
BALTIC_CHARSET |
You'll need to include the Windows API to access those.
For example,
Code: |
private import dfl.all, dfl.winapi;
// ...
mylabel.font = new Font("My Font Name", 11f, FontStyle.REGULAR, GraphicsUnit.POINT, SHIFTJIS_CHARSET);
|
I'm not sure what you meant by "The charset has to be in ubyte, rather than in a string". Do you mean you don't want to use Unicode? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|