Subject |
Re: is dBase pluse an unicode application? |
From |
Bernard Mouille <bernard.mouille@free.fr> |
Date |
Sun, 21 Feb 2021 15:28:26 -0500 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
Test.txt |
Hello Eric,
I do not knows if the attached code good works for convert to unicode.
Regards,
Bernard.
Eric Wu Wrote:
> is dBase pluse 2019 an unicode application?
>
> Eric
| /*
Test.prg.
Essai de convertir une chaîne Ansi en chaîne Unicode.
J'ai le même résultat que win_AnsiToWide.
This code is a basic sample.
https://docs.microsoft.com/fr-fr/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar?redirectedfrom=MSDN
https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte
https://docs.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getacp
*/
#define CP_ACP 0
#define CP_THREAD_ACP 3
#define MB_COMPOSITE 2 // Enlève les accents.
#define MB_PRECOMPOSED 1
#define WC_COMPOSITECHECK 512
local i // Numérique de comptage.
local c // Caractère à traiter.
local cw // Caractère unicode de retour MultiByteToWideChar().
local cCodePage // Code page du système.
local nChars // Nombre de caractères de la chaîne de retour MultiByteToWideChar().
local cAnsi // chaîne Ansi à transformer.
local cWide // Chaîne unicode de retour.
local cTest // Chaîne Ansi de test.
if not type( "MultiByteToWideChar" ) == "FP"
extern CINT MultiByteToWideChar( CUINT, CULONG, CSTRING, CINT, CSTRING, CINT ) Kernel32.dll
endif
if not type( "WideCharToMultiByte" ) == "FP"
extern CINT WideCharToMultiByte( CUINT, CULONG, CSTRING, CINT, CSTRING, CINT, CSTRING, CLOGICAL ) Kernel32.dll
endif
if not type( "GetACP" ) == "FP"
extern CINT GetACP( CVOID ) Kernel32.dll
endif
if new file().exists( "_Result.txt" )
new file().delete( "_Result.txt" )
endif
set alte to _Result.txt
set alte on
? "Test programme Ansi to Wide."
?
cCodePage = GetACP()
? "Code page :", cCodePage
cAnsi = "l'été à Plan d'Aups, c'est même très bien."
cWide = ""
cTest = ""
? "Len( cAnsi ) :", Len( cAnsi )
?
? cAnsi
?
for i = 1 to len( cAnsi )
c = subs( cAnsi, i, 1 )
cw = space( 2 )
nChars = MultiByteToWideChar( cCodePage, MB_PRECOMPOSED, c, len( c ) ;
, cw, len( cw ) )
cWide += cw
c = space( 1 )
nChars = WideCharToMultiByte( cCodePage, WC_COMPOSITECHECK, cw, len( cw ) ;
, c, len( c ), null, null )
cTest += c
endfor
? cWide
?
? cTest
?
?
set alte off
set alte to
if not type( "ShellExecute" ) == "FP"
extern CHANDLE ShellExecute( CHANDLE, CSTRING, CSTRING, CSTRING, CSTRING, CINT ) ;
Shell32.dll from "ShellExecuteA"
endif
ShellExecute( 0, "open", set( "directory" ) + "\_Result.txt", null, null, 1 )
return
|
|