text encoding when opening textfile

This is a discussion on text encoding when opening textfile within the Clipper forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > Clipper

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-02-2008, 09:38 AM
Paul D B
Guest
 
Default text encoding when opening textfile

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

Reply With Quote
  #2  
Old 09-02-2008, 06:52 PM
Stephen Quinn
Guest
 
Default Re: text encoding when opening textfile

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



Reply With Quote
  #3  
Old 09-03-2008, 03:38 AM
Robert van der Hulst
Guest
 
Default Re: text encoding when opening textfile

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

Reply With Quote
  #4  
Old 09-03-2008, 05:15 AM
Paul D B
Guest
 
Default Re: text encoding when opening textfile

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

Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:00 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.