>>>>
>>>>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
If I get the value from SQL Server, I don't get the string above. I get a 4 bytes per character string. You missed the step of retrieving the value from SQL Server.
>(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)
!!!!!!!!!!!!! But I don't know which language I am displaying - that's the whole point!
>(4) retrieve the value
>(5) set the original value of sys(3101) back
>(6) convert the value to utf-16
Ok, I'll try.
Although two extra steps are missing in your tests:
1. Retrieve data from nvarchar(100) field
...
5. Save data back to nvarchar(100) field
6. Try with different languages (don't know in advance which) and all different languages need to show correctly on the same form.
If it's not broken, fix it until it is.
My Blog