shawn857
asked on
Want to write greek summation character "S"
Hi, I simply want to write to a text fie (using writeln) the Greek character for summation - S. But when I'm coding and I try to paste that character in my writeln statement, it just shows as the letter "S". How can I write this character out to my text file?
Thanks!
Shawn
P.S: I'm using Delphi 7
Thanks!
Shawn
P.S: I'm using Delphi 7
Hope you understand what I mean!
Not really, do you still have a problem?
ASKER
Yes, I simply want to be able to output the greek character for summation (see http://fsymbols.com/signs/sigma/) to a text file using a writeln statement. Any ideas? is there some escape code or ordinal code that will allow me to write out this special character?
Thanks
Shawn
Thanks
Shawn
WriteLn in Delphi 7 doesn't support unicode, so outcome will depend on the codepage used locally (so not something you can trust on it will work always / everywhere).
Why do you need to use WriteLn?
Why do you need to use WriteLn?
In Delphi 7, the VCL is still based on Ansi, not Unicode. You have to make sure the Sigma character is encoded in AnsiString
ASKER
Thanks Livestuff... how do I do all this? I've never dealt in different character sets in Delphi.
Thanks
Shawn
Thanks
Shawn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Merjin... what is a BOM, by the way? I'm a total newbie when it comes to this Unicode stuff. So will I still be able to write all my other regular text to my text file as normal? Or will this UTF format mess everything up? The file I'm trying to write is completely normal (ie. ascii) except for this one greek character I'd like to output.
Thanks
Shawn
Thanks
Shawn
In (very) short:
BOM stands for Byte Order Mark. Unicode comes in a few different flavors, of which UTF-8 looks the most like ansi. Each flavor has it's own BOM, such a BOM is placed as the very first bytes in a file. It's simply to tell whoever is viewing the file: this file is encoded as UTF-8.
You could get in trouble if you currently write characters from the upper half of the ascii table ( Chr(128) and up), these are the chars like: æ, ò and Û. It's probably best to try this and see if everything looks ok.
Who or what is reading the file, should you be able to read the file using Delphi as well?
BOM stands for Byte Order Mark. Unicode comes in a few different flavors, of which UTF-8 looks the most like ansi. Each flavor has it's own BOM, such a BOM is placed as the very first bytes in a file. It's simply to tell whoever is viewing the file: this file is encoded as UTF-8.
You could get in trouble if you currently write characters from the upper half of the ascii table ( Chr(128) and up), these are the chars like: æ, ò and Û. It's probably best to try this and see if everything looks ok.
Who or what is reading the file, should you be able to read the file using Delphi as well?
ASKER
Oh okay. Are these BOM bytes visible in my output file? I'm simply creating a very plain vanilla report file that looks something like this:
Subtotal: <CallerID_1> FILE 1 FILE 2
---------------------- ------ ------
1302873831 Count : 2
Sum : 9.0000
1782513168 Count : 2
Sum : 7.0000
... and instead of the word "Sum", I want to show the greek sigma character. (instead of "Count" I will show the "#" sign instead). Nothing complicated.
No, I don't write any characters above Chr(128) - I only write out normal readable characters. Shouldn't be any problem there.
It's simply a report file that will be eyeballed by the end-user, and maybe printed out. That brings up a question - will the sigma character print okay?
Also, the file will not be read as input.
Thanks!
Shawn
Subtotal: <CallerID_1> FILE 1 FILE 2
---------------------- ------ ------
1302873831 Count : 2
Sum : 9.0000
1782513168 Count : 2
Sum : 7.0000
... and instead of the word "Sum", I want to show the greek sigma character. (instead of "Count" I will show the "#" sign instead). Nothing complicated.
No, I don't write any characters above Chr(128) - I only write out normal readable characters. Shouldn't be any problem there.
It's simply a report file that will be eyeballed by the end-user, and maybe printed out. That brings up a question - will the sigma character print okay?
Also, the file will not be read as input.
Thanks!
Shawn
In Delphi 7, Unicode characters can become a mess. If I were you, I would save yourself time and hassle and leave sum just as it is "Sum" or better yet "Total"
Hi Shawn,
The answer to both your questions depends on what the end user is using to view and print the report. If the end user is using an editor which properly supports unicode (which is almost every somewhat recent edigor) you won't see the bom and printing should be fine. Try opening the file yourself in notepad.exe and you'll see that works fine.
Though I agree with livestuff that this could get messy in Delphi 7,since you only write the file here and that's it, I don't think you'll have any problems.
The answer to both your questions depends on what the end user is using to view and print the report. If the end user is using an editor which properly supports unicode (which is almost every somewhat recent edigor) you won't see the bom and printing should be fine. Try opening the file yourself in notepad.exe and you'll see that works fine.
Though I agree with livestuff that this could get messy in Delphi 7,since you only write the file here and that's it, I don't think you'll have any problems.
ASKER
Well, ultimately I do plan to have my app create my report internally in QuickReport and allow the user to choose his form of output - ie. PDF, HTML, CSV, XL, ASCII, etc. So it might start getting a little messy then... that greek character might screw everything up for those different output types eh? Maybe I better not open this can of worms at all, and just stick with the word "Sum" in my report instead of the greek character.
Shawn
Shawn
That will depend on whether quickreport supports unicode (widestring) or not.
If you update your Delphi version there won't be an issue at all.
You can keep it in now, and switch back to "sum" later if you run into trouble I'd say :)
If you update your Delphi version there won't be an issue at all.
You can keep it in now, and switch back to "sum" later if you run into trouble I'd say :)
ASKER
Merjin. do you mean update my version of Delphi, or update my version of Quickreports?
Thanks
Shawn
Thanks
Shawn
Shawn, probably both.
ASKER
Thank you Merjin
Cheers
Shawn
Cheers
Shawn
ASKER
Thanks
Shawn