Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to transform text file from Unicode UTF8 to Windows1
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01401743
Message ID:
01401758
Vues:
54
Dear Boris
That code seems like a step into the right direction. Do you know what is the CodePage code for UTF8?

Jaime

>>Dear Gregory
>>I already tried that previously, but no success. By the way, i never converted to singlebyte before, i stopped at the dbcs phase, and in this case the result is the same: i see hebrew characters allright, but they're inversed.
>>Tried also STRCONV(STRCONV(lss,12),6, 1255, 1 ) but i get the same ( ie inversed hebrew strigs )
>>
>>Jaime
>
>Try this function:
>
>lcFile = GETFILE([DAT])
>lcString = FILETOSTR(lcFile)
>lcTestMe = udf_CPConverter(28598,1255, lcString)
>STRTOFILE(lcTestMe, [Test1255.TXT])
>lcTestMe = udf_CPConverter(1255, 28598, lcTestMe)
>STRTOFILE(lcTestMe, [Test28598.TXT])
>
>
>FUNCTION udf_CPConverter()
>Lparameters nCurrentCodePage, nNewCodePage, cString )
>
>Declare Integer IsValidCodePage in WIN32API ;
>     integer nCodePage
>
>Declare Integer MultiByteToWideChar in WIN32API ;
>     integer CodePage,;
>     integer Flags,;
>     string MultyByteStr,;
>     integer MultiByteStrLen,;
>     string @ WideCharStr,;
>     integer WideCharStrLen
>
>
>Declare Integer WideCharToMultiByte in WIN32API ;
>     integer CodePage,;
>     integer Flags,;
>     string MultyByteStr,;
>     integer MultiByteStrLen,;
>     string @ WideCharStr,;
>     integer WideCharStrLen,;
>     integer ,;
>     integer 
>
>
>If IsValidCodePage(nCurrentCodePage) = 0
>     ERROR 1914
>     RETURN ""
>EndIf
>
>If IsValidCodePage(nNewCodePage) = 0
>     ERROR 1914
>     RETURN ""
>EndIf
>
>Local WideCharBuf, MultiByteBuf
>WideCharBuf  = REPLICATE(CHR(0),LEN(cString)*2)
>MultiByteBuf = REPLICATE(CHR(0),LEN(cString))
>
>MultiByteToWideChar;
>     (nCurrentCodePage;
>     ,0;
>     ,cString;
>     ,Len(cString);
>     ,@WideCharBuf;
>     ,Len(WideCharBuf))
>
>
>WideCharToMultiByte;
>     (nNewCodePage;
>     ,0;
>     ,WideCharBuf;
>     ,Len(WideCharBuf);
>     ,@MultiByteBuf;
>     ,Len(MultiByteBuf);
>     ,0,0)
>
>Return MultiByteBuf
>
>*!*    Code Page Identifiers for ISO-8859 are:
>
>*!*    28591 ISO 8859-1 Latin I
>*!*    28592 ISO 8859-2 Central Europe
>*!*    28593 ISO 8859-3 Latin 3
>*!*    28594 ISO 8859-4 Baltic
>*!*    28595 ISO 8859-5 Cyrillic
>*!*    28596 ISO 8859-6 Arabic
>*!*    28597 ISO 8859-7 Greek
>*!*    28598 ISO 8859-8 Hebrew
>*!*    28599 ISO 8859-9 Latin 5
>*!*    28605 ISO 8859-15 Latin 9
>
>
>
>Not mine, but kill me if I remember who wrote it.
>I use it a long time, but when I copy it I forgot to write the Author :-(
>
>(That was a looooong time ago)
Why do programs stop working correctly as soon as you leave the Fox?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform