Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Character Sets
Message
De
11/09/2014 07:35:45
 
 
À
11/09/2014 07:28:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01607355
Message ID:
01607388
Vues:
43
>>Hi All
>>
>>I am receiving text (TXT) files from a 3rd party entity. I read the file in using FILETOSTR(), amend it, and then write it out to another TXT file using STRTOFILE(). Someone has now asked me what character set we are using for the output file. How do I find that out or answer this question?
>>
>>TIA
>
>The simple answer you already know by now: STRTOFILE() does not operate any conversion on the string. So, what you're giving back is what you got in the first place. If you change anything in the string before saving it again to disk, and unless you don't use any STRCONV() or manual conversion (which, obviously, you are not), then you're using Windows-1252, aka Windows-ANSI, or ANSI for short, in your modifications.
>
>If you need to programmaticaly perform any codepage changes, then read the file, as you are doing, eventually perform a first STRCONV() to ANSI because that's the codepage you'll be working with, do all of your magic stuff, STRCONV() back to the codepage the third party entity needs, and then save with STRTOFILE() (eventually with BOM, if that is what the other end requires).
>
>In VFP, the list of supported codepages may be seen by issuing GETCP(). Of course, a file is just a sequence of bytes: if the target code page is not suported by VFP, you just create a conversion function of your own.
>
>Just remember that the conversion process may not be lossless. An example:
>
>CREATE CURSOR curAuthors (author M)
>
>INSERT INTO curAuthors VALUES ("Antoine de Saint-Exupéry")
>
>COPY MEMO author TO ansi.txt
>COPY MEMO author TO cp1253.txt AS 1253
>
>INSERT INTO curAuthors VALUES ("Jaroslav Hašek")
>
>COPY MEMO author TO ansi.txt ADDITIVE
>COPY MEMO author TO cp1253.txt AS 1253 ADDITIVE
>
>
>Side note:
>BOM does not denote character sets and serve only as a hint to the character codepoint encoding, that is, the way the character set codepoints are encoded in the byte stream. ANSI files, for instance, may be encoded using UTF-8. BOM use is optional and a consumer system may even complain to its presence (in fact, its implementation was an unfortunate decision that I suspect the UNICODE consortium now regrets...).
>
>The question you were asked must be interpreted as part of a negotiation between two systems, one that normally occurs in the absence of an established interchange convention. Once set, it's just a matter of going by the rules. So, what you could answer and ask back is: "It's Windows-1252. What do you need?"


Antonio, thanks very much for this answer. You and the others have clarified it for me and I can answer the client appropriately. Thanks.
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform