Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Saving unicode data
Message
De
28/12/2011 06:12:24
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01531693
Message ID:
01531769
Vues:
75
This message has been marked as a message which has helped to the initial question of the thread.
J'aime (2)
>>>
>>>One Russian character corresponds to 4 characters in varbinary / binary.


Wrong - the data in the russian record is UTF-16 or wide char or 2 bytes per character


I have taken a computer win7 64 and office 32 bits and .... I have the msforms 2 textbox

(1) I've made a form with a msforms textbox on it

load
CREATE CURSOR csrTest (cVal blob, nVal blob)

INSERT INTO  csrTest ;
    VALUES;
   (STRCONV( "Russian",5),;
     STRCONV("EQQ+BDsETARIBD4EOQQgAEYEMgQ1BEIEPQQ+BDkEIAAyBD0EQwRCBEAENQQ9BD0EOAQ5BCAANAQ4BEEEPwQ7BDUEOQQ=",14)  )
Mind you, strconv('Russian', 5) - does not make sense to me

(2) Command1.Click - assign value
this.Parent.Text1.Text = csrTest.nVal 
After I click I see the following - see attached

(3) If I try to get the value back, I get the question marks as well because the activeX tries to convert its utf-16 to my current code page (1252)

I get around by
(a) temporarily setting my COM codepage to 1251 (Cyrillic)
(b) retrieving the value
(c) setting my COM code page back

The value retrieved is now in code page 1251, and hence one byte/char

(d) I convert the value to UTF-16 and compare to the original value - and they are equal

Command2.click - get value back
local xx, utf16Out, oldCodepage


oldCodepage =sys(3101, 1251)

xx = this.Parent.Text1.Text

=sys(3101, m.oldCodepage)

= StringToUTF16(@m.utf16Out, m.xx, 1251)

acti screen
?strconv(csrTest.nval, 15)
11043E043B044C0448043E043904200046043204350442043D043E043904200032043D0443044204400435043D043D043804390420003404380441043F043B0435043904

?strconv(utf16Out, 15)
11043E043B044C0448043E043904200046043204350442043D043E043904200032043D0443044204400435043D043D043804390420003404380441043F043B0435043904

?'Same value ', csrTest.nval == utf16Out

Same value  .T.
You will find the function StringToUTF16() in the link in one of my previous messages



So, it's very simple


(1) the msforms accepts UTF-16
(2) And gives its value back in the 'current' code page - which is a bad conversion
(3) swith to the code page of the language you're displaying with sys(3101)
(4) retrieve the value
(5) set the original value of sys(3101) back
(6) convert the value to utf-16
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform