Jump to content

Thai Text File


Niloc

Recommended Posts

I have written a small program to allow the local health centre to keep track of the expiry dates of the medicines it dishes out to the residents.

The program uses a text file to hold messages used to advise the user what is required, like a help file.

It works OK with English but when I store the text in Thai, all I get is a string of '?' when I read the file.

I have installed Thai font etc and I can get it to work by hardcoding strings as #40 + #41 etc so I know it works but how can I get the text editor to accept and store Thai characters?

I reckon it is the editor swapping all the Thai characters for '?', do I need another editor?

Any help appreciated...

Link to comment
Share on other sites


Thanks Tywais but my text file looks something like this :

[3002] Choose a stock item first from the list

[3003] The stock item needs a name

[3004] You must enter the number of items purchased

[3005] The stock Expiry Date must be later than today

So when I open it with Notepad and save it as Unicode, it spoils the [####] part and my program can't read it....

Maybe I should just change it to an array of ASCI codes and rewrite the message reading part to interpret? That would mean I would have to write all the messages in Thai and write a quickie to convert every message to ASCII.... so a message would look like "[3005]41,42,45,69,etc??

Link to comment
Share on other sites

Maybe I should just change it to an array of ASCI codes and rewrite the message reading part to interpret? That would mean I would have to write all the messages in Thai and write a quickie to convert every message to ASCII.... so a message would look like "[3005]41,42,45,69,etc??

What programming language are you using? It appears your formatting on reading from the file is the problem and not the editor. Might try and read in binary format rather then ascii since Unicode uses two 8-bit bytes to determine the characters while ASCII is 7-bit (normally one byte) .

Edited by tywais
Link to comment
Share on other sites

I am using Delphi 7. I wrote a Thai txt to Thai braille a few years back and I seem to recall that the Thai had ASCII codes for every char? If that was the case, it would be easy.

I see your point re binary but I want the messages file to be 'editable' so the user can change the messages to suit himself, if it was binary I would have to give him a conversion program to do this and explain how to use it etc...

If there are ASCII codes for Thai characters, can you point me to a website where I can find these?

Thank you for your assistance, and no, I am not going to rewrite the whole thing in C++ or FORTRAN!

Link to comment
Share on other sites

Thank you for your assistance, and no, I am not going to rewrite the whole thing in C++ or FORTRAN!

There's nothing wrong with Pascal and Delphi is an excellent programming enviornment so I certainly won't say change languages. My suggestions regarding saving as unicode was actually not correct for this situtation (Thai). You can save it as UTF-8 which then allows single bytes per character. Also make sure your display boxes in Delphi are set to a standard Thai font such as any of the UPC versions, example AngsanaUPC. Just tried it in Visual Basic (my language of choice) and it is nearly correct, some parsing needed is all.

Link to comment
Share on other sites

Excellent. I looked at my Delphi help and it has UTF8 encode/decode/ToAscii etc so I will have a good look at that.

There is also a function which "Converts null-terminated Unicode string to single or multi byte character data" which would convert the Unicode string from Notepad to ASCII hopefully so I could use Notepad to create/edit the text file and 'Bobs your Uncle'!!

Problem solved, hopefully!!

Thanks,

Colin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.








×
×
  • Create New...
""