| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi all, I have to process textfiles that are (sometimes) made on a Macintosh. All accented characters are a mess then. So, two questions: - how do I know the encoding of a textfile? I suppose you can't tell (I've looked at the file with a hex editor). But I could give the user a checkbox to check when it is a Mac file... which brings me to the next question: - how can I tell VO to open the file with a specific encoding? TIA -- Paul |
|
#2
| |||
| |||
| Paul > I have to process textfiles that are (sometimes) made on a Macintosh. All > accented characters are a mess then. AFAIK Mac & Windows text files differ only in the EOL characters (LF/CRLF or is it CR/CRLF). Are you asking about UTF encoded files?? I'd expect the file to have the encoding used as the first line of text then. If they are encoded and there is no way to identify the encoding used, then I think you'll be PSU with a toothbrush to do a reliable job of processing of them. OR Do you need to do a bigEndian/littleEndian (aka byte swap) conversion. CYA Steve |
|
#3
| |||
| |||
| Hi Paul, On Tue, 2 Sep 2008, at 15:38:42 [GMT +0200] (which was 15:38 where I live) you wrote about: 'text encoding when opening textfile' > I have to process textfiles that are (sometimes) made on a Macintosh. > All accented characters are a mess then. > So, two questions: > - how do I know the encoding of a textfile? I suppose you can't tell > (I've looked at the file with a hex editor). But I could give the user a > checkbox to check when it is a Mac file... which brings me to the next > question: > - how can I tell VO to open the file with a specific encoding? The UTIL module in the System Library VO 2.8 has a ConvertFromCodePageToCodePage function. Read the string with MemoRead(), pass one of the MAC codepages (for example 10029, see http://en.wikipedia.org/wiki/Code_page) in the FromCodepage and CP_ACP (Active Windows Codepage) in the to codepage. -- Robert van der Hulst AKA Mr. Data Vo2Jet & Vo2Ado Support VO & Vulcan.NET Development Team www.heliks.nl |
|
#4
| |||
| |||
| Robert van der Hulst wrote: > Hi Paul, > On Tue, 2 Sep 2008, at 15:38:42 [GMT +0200] (which was 15:38 where I > live) you wrote about: 'text encoding when opening textfile' > >> I have to process textfiles that are (sometimes) made on a Macintosh. >> All accented characters are a mess then. > >> So, two questions: >> - how do I know the encoding of a textfile? I suppose you can't tell >> (I've looked at the file with a hex editor). But I could give the >> user a checkbox to check when it is a Mac file... which brings me to >> the next question: >> - how can I tell VO to open the file with a specific encoding? > > > The UTIL module in the System Library VO 2.8 has a > ConvertFromCodePageToCodePage function. Read the string with > MemoRead(), pass one of the MAC codepages (for example 10029, see > http://en.wikipedia.org/wiki/Code_page) in the FromCodepage and CP_ACP > (Active Windows Codepage) in the to codepage. Hi Robert (and Steve) YES YES YES! That does the trick, works great!!! Just what I was looking for. This function is a hidden gem (anymore of those?) It might even be useful for translating old OEM DBF's from one codepage to another. PS: the file is made with a very old (1998) program on a Mac (an old one I guess <g>). It is a simple txt file (tab-delimited) encoded with Mac Roman (10000 Code page) many thanks, you've saved my day -- Paul |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.