Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Chinese Language Character Stuff in Dark Basic Pro (unicode to gb2312 and back) - The solution

Author
Message
xjoyride
16
Years of Service
User Offline
Joined: 23rd Oct 2008
Location:
Posted: 26th Oct 2008 08:06
Woot, I've done it. Man, I've been trying to input Chinese string into Darkbasic forever, I'm glad I finally found out how. I had to do some intense research into the nature of fonts and stuff, it was -like I said- intense. And now, I would like to share it with you (since the support I found on the forums wasn't so helpful). So, if you've tried to put Chinese characters into your program, and it hasn't worked (you've either gotten ???? or the wrong characters) then this really super basic tutorial is for you.

1. The information
So, as everyone knows there are several ways of encoding characters (different numerical representations for referencing characters on an operating system. See Note 1 at bottom). The basic text editor, Notepad (in Windows), can use several different codes to save your data (saves it in different ways, so that different programs can access it, depending on what system of codes that other program uses). Unfortunatley, notepad (and windows input method editor or IME) does not use the same system of encoding that DarkBasic Pro uses. So, all the code on the forums stating "Just use 'Set text font "arial", 134'" *(See Note 2) won't be of any help, because the only practical way to input the characters into Darkbasic IDE (the thing you type into before you compile your program) is using an IME, which is not supported by darkbasic (doesn't support unicode). Dark Basic supports gb2312 encoding (specifically for Chinese charactes). So, what you have to do, is somehow find a way to input gb2312 codes into darkbasic, instead of using unicode (or instead of using gb18030 - another 'Chinese' way to encode characters. Some IME's use gb18030 and some use unicode. If you don't understand this, don't worry, its not really important). But notepad and your IME don't support gb2312...so you have a problem....or rather, you HAD a problem. Because now you can use http://www.mandarintools.com/zhcode.html . What you have to do, is type the Chinese text you want to use in Darkbasic Pro, into a txt file using notepad (open notepad, type what you want in Chinese, and then save in it unicode format (look in the 'save as' dialogue box beside the 'encoding label', by default it will say ANSI, click it and change it to Unicode)). Then go to http://www.mandarintools.com/zhcode.html and upload the file into where it says "source file name" then choose where to save it using "target file name" (which acts like "save as" in other programs). If you open this new file, it will look like gibberish (not understandable text). Copy all of this gibberish and paste it into darkbasic wherever you wanted the Chinese string. Make sure you use the "set text font fontNameInQuotes, 134" (134 refers to note 2, it is sub-set of characters within a larger encoding system) before you try to print the Chinese string or use it in any way, otherwise when you want to display it, it will appear as the same gibberish as you saw in the darkbasic pro IDE, instead of as the beautifully formed Chinese characters that are supposed to be displayed. If you have any questions, I will probably not answer them as I am destined to be as unhelpful as possible (actually, I just post stuff and forget about it, so I don't get around to answering questions). Because of my memory span, I have tried to make this as basic as possible. On second thought, if you have questions, please do post them, I'll try and check back here on a reasonable basis. I hope this has been basic enough as I haven't gotten much sleep in the past...too long to remember...shakes fist at mid-terms and late night university study sessions...













Note 1: If you own a PC and have XP, go to the Character Map program located in Start->Accessories->System Tools, and play around a bit, you'll notice that at the bottom of the window there appears a little bit of text (U+ and then four characters in Hex, if you don't know what hex is, goto http://en.wikipedia.org/wiki/Hexadecimal) that changes every time you click on a different character (letter, number or symbol). This is the "Unicode" system of encoding characters (for more info, see http://en.wikipedia.org/wiki/Unicode), it is one of many different ways to represent characters.


Note 2:
DEFAULT_CHARSET 1
SYMBOL_CHARSET 2
SHIFTJIS_CHARSET 128 (Japanese)
HANGEUL_CHARSET 129 (Korean)
HANGUL_CHARSET 129
GB2312_CHARSET 134 (Simplified Chinese)
CHINESEBIG5_CHARSET 136 (Traditional Chinese)
OEM_CHARSET 255
JOHAB_CHARSET 130
HEBREW_CHARSET 177
ARABIC_CHARSET 178
GREEK_CHARSET 161
TURKISH_CHARSET 162
VIETNAMESE_CHARSET 163
THAI_CHARSET 222
EASTEUROPE_CHARSET 238
RUSSIAN_CHARSET 204
MAC_CHARSET 77
BALTIC_CHARSET 186

(Look up 'Set Text Font' in Darkbasic API (Help files))
xjoyride
16
Years of Service
User Offline
Joined: 23rd Oct 2008
Location:
Posted: 26th Oct 2008 19:33
So, if anybody else has had success in the area of language and DBPro, let me know.

Login to post a reply

Server time is: 2025-06-18 06:21:23
Your offset time is: 2025-06-18 06:21:23