>>PUBLIC oform1 >> >>oform1=NEWOBJECT("form1") >>oform1.Show >>RETURN >> >> >> ************************************************** >>*-- Form: form1 (d:\project9\coreframe\core\yy.scx) >>*-- ParentClass: form >>*-- BaseClass: form >>*-- Time Stamp: 12/28/11 04:35:02 PM >>* >>DEFINE CLASS form1 AS form >> >> >> Top = 0 >> Left = 0 >> Height = 390 >> Width = 551 >> DoCreate = .T. >> Caption = "Form1" >> Name = "Form1" >> >> >> ADD OBJECT text1 AS olecontrol WITH ; >> Top = 72, ; >> Left = 12, ; >> Height = 93, ; >> Width = 372, ; >> Name = "text1" >> >> >> ADD OBJECT command1 AS commandbutton WITH ; >> Top = 12, ; >> Left = 48, ; >> Height = 25, ; >> Width = 97, ; >> Caption = "Assign value", ; >> Name = "Command1" >> >> >> ADD OBJECT command2 AS commandbutton WITH ; >> Top = 12, ; >> Left = 192, ; >> Height = 25, ; >> Width = 97, ; >> Caption = "Get value back", ; >> Name = "Command2" >> >> >> PROCEDURE Load >> CREATE CURSOR csrTest (cVal blob, nVal blob) >> >> INSERT INTO csrTest ; >> VALUES; >> (STRCONV( "Russian",5),; >> STRCONV('20044304410441043A0438043904',16) ) >> ENDPROC >> >> >> PROCEDURE command1.Click >> >> =comprop(this.Parent.Text1, 'utf8', 1) >> >> this.Parent.Text1.Text = csrTest.nVal >> ENDPROC >> >> >> PROCEDURE command2.Click >> local utf8, utf16Out >> utf8 =m.this.Parent.text1.Text >> >> >> = StringUtf8ToUTF16(@m.utf16Out, m.utf8) >> >> acti screen >> ?strconv(csrTest.nval, 15) >> ?strconv(utf16Out, 15) >> >> ?'Same value ', csrTest.nval == utf16Out >> assert .f. >> ENDPROC >> >> >>ENDDEFINE >>* >>*-- EndDefine: form1 >>************************************************** >>>>
>>#include "Foxpro.h" >>#define true .t. >>#define false .f. >> >>*_______________________________________________________________________________ >>function StringToUTF8(utf8Out, stringIn, codepageIn) >> >> local success >> success = true >> >> do case >> case !m.success >> >> case !StringToUTF16(@m.utf8Out, m.stringIn, m.codepageIn) >> assert false >> success = false >> >> case !StringUTF16ToUTF8(@m.utf8Out, m.utf8Out) >> assert false >> success = false >> >> endcase >> >> return m.success >> >>endfunc >>*_______________________________________________________________________________ >> >> >>*_______________________________________________________________________________ >>*_______________________________________________________________________________ >>#define CP_ACP 0 >>#define CP_MACCP 2 >>#define CP_OEMCP 1 >>#define CP_SYMBOL 42 >>#define CP_THREAD_ACP 3 >>#define CP_UTF7 65000 >>#define CP_UTF8 65001 >>#define MB_PRECOMPOSED 0x1 >>#define MB_COMPOSITE 0x2 >>#define MB_USEGLYPHCHARS 0x4 >>#define MB_ERR_INVALID_CHARS 0x8 >> >>#define WC_DEFAULTCHAR 0x00000040 >>#define WC_ERR_INVALID_CHARS 0x00000080 >>#define WC_NO_BEST_FIT_CHARS 0x00000400 >>*_______________________________________________________________________________ >>function StringToUTF16(utf16Out, stringIn, codepageIn) >> >> local success >> success = true >> >> do case >> case !m.success >> >> case empty(len(m.stringIn)) >> utf16Out = '' >> >> otherwise >> local lpWideCharStr, result >> lpWideCharStr = space(len(m.stringIn)*2) >> >> result = MultiByteToWideChar( ; >> evl(m.codepageIn, cpcurrent()), ; >> MB_ERR_INVALID_CHARS, ; >> @m.stringIn, ; >> len(m.stringIn), ; >> @m.lpWideCharStr, ; >> len(m.lpWideCharStr) ; >> ) >> >> do case >> case !m.success >> >> case empty(m.result) >> assert false >> success = false >> >> otherwise >> utf16Out = left(m.lpWideCharStr, m.result * 2) >> >> endcase >> >> endcase >> >> return m.success >> >> >>endfunc >>*_______________________________________________________________________________ >>function StringUTF16ToUTF8(utf8Out, utf16In) >> >> local success >> success = true >> >> do case >> case !m.success >> >> case empty(len(m.utf16In)) >> utf8Out = '' >> >> otherwise >> >> local lpMultiByteStr, lpUsedDefaultChar, result >> lpMultiByteStr = space(len(m.utf16In) * 2) >> lpUsedDefaultChar = 0 >> >> result = WideCharToMultiByte( ; >> CP_UTF8, ; >> WC_ERR_INVALID_CHARS, ; >> @m.utf16In, ; >> len(m.utf16In)/2, ; >> @m.lpMultiByteStr, ; >> len(m.lpMultiByteStr), ; >> null, ; >> @m.lpUsedDefaultChar ; >> ) >> >> do case >> case !m.success >> >> case empty(m.result) >> assert false >> success = false >> >> >> otherwise >> utf8Out = left(m.lpMultiByteStr, m.result) >> >> endcase >> endcase >> >> return m.success >> >> >> >>endfunc >>*_______________________________________________________________________________ >>function StringUTF8ToUTF16(utf16Out, uft8In) >> >> return StringToUTF16(@m.utf16Out, uft8In, CP_UTF8) >> >>endfunc >>*_______________________________________________________________________________ >> >>function MultiByteToWideChar >> lparameters codepage, ; >> dwFlags, ; >> lpMultiByteStr, ; >> cbMultiByte, ; >> lpWideCharStr, ; >> cchWideChar >> >> local success >> success = true >> >> local result >> >> do case >> case !m.success >> >> otherwise >> try >> declare integer MultiByteToWideChar in Kernel32.dll ; >> long codepage, ; >> long dwFlags, ; >> string@ lpMultiByteStr, ; >> integer cbMultiByte, ; >> string@ lpWideCharStr, ; >> integer cchWideChar >> >> result = MultiByteToWideChar( ; >> m.codepage, ; >> m.dwFlags, ; >> @m.lpMultiByteStr, ; >> m.cbMultiByte, ; >> @m.lpWideCharStr, ; >> m.cchWideChar ; >> ) >> catch >> assert false >> success = false >> >> endtry >> endcase >> >> return iif(m.success, m.result, 0) >> >>endfunc >>*_______________________________________________________________________________ >>function WideCharToMultiByte >> lparameters codepage, ; >> dwFlags, ; >> lpWideCharStr, ; >> cchWideChar, ; >> lpMultiByteStr, ; >> cbMultiByte, ; >> lpDefaultChar, ; >> lpUsedDefaultChar >> >> local success >> success = true >> >> local result >> >> do case >> case !m.success >> >> otherwise >> try >> declare integer WideCharToMultiByte in Kernel32.dll ; >> long codepage, ; >> long dwFlags, ; >> string@ lpWideCharStr, ; >> integer cchWideChar, ; >> string@ lpMultiByteStr, ; >> integer cbMultiByte, ; >> string lpDefaultChar, ; >> integer @lpUsedDefaultChar >> >> result = WideCharToMultiByte ( ; >> m.codepage, ; >> m.dwFlags, ; >> @m.lpWideCharStr, ; >> m.cchWideChar, ; >> @m.lpMultiByteStr, ; >> m.cbMultiByte, ; >> m.lpDefaultChar, ; >> @m.lpUsedDefaultChar; >> ) >> catch >> assert false >> success = false >> >> endtry >> endcase >> >> return iif(m.success, m.result, 0) >> >>endfunc >>*_______________________________________________________________________________ >>>
>DODEFAULT() >set multilocks on &&necessary for all types of buffering >cursorsetprop("MapBinary", .T., 0) >IF NOT UPPER('StringConvertFunctions') $ UPPER(SET("Procedure")) > > SET PROCEDURE TO StringConvertFunctions additive >ENDIF > >LOCAL lcSQL >TEXT TO lcSQL noshow >SELECT pri_key > ,defltlang > ,cast(language00 as varbinary(100)) as language00 > ,lngimage00 > ,cast(language01 as varbinary(100)) as language01 > ,lngimage01 > ,cast(language02 as varbinary(100)) as language02 > ,lngimage02 > ,cast(language03 as varbinary(100)) as language03 > ,lngimage03 > ,cast(language04 as varbinary(100)) as language04 > ,lngimage04 > ,cast(language05 as varbinary(100)) as language05 > ,lngimage05 > ,cast(language06 as varbinary(100)) as language06 > ,lngimage06 > ,cast(language07 as varbinary(100)) as language07 > ,lngimage07 > ,cast(language08 as varbinary(100)) as language08 > ,lngimage08 > ,cast(language09 as varbinary(100)) as language09 > ,lngimage09 > ,cast(language10 as varbinary(100)) as language10 > ,lngimage10 > FROM dbo.prefs_sl >endtext >mysqlexec(m.lcSQL, 'Prefs_sl', program()) > >if reccount()=0 > append blank >ENDIF > >*!* SELECT pri_key, defltlang, ; >*!* CAST(STRCONV(language00,16) as Blob) as language00, ; >*!* CAST(STRCONV(language01,16) as Blob) as language01, ; >*!* CAST(STRCONV(language02,16) as Blob) as language02, ; >*!* CAST(STRCONV(language03,16) as Blob) as language03, ; >*!* CAST(STRCONV(language04,16) as Blob) as language04, ; >*!* CAST(STRCONV(language05,16) as Blob) as language05, ; >*!* CAST(STRCONV(language06,16) as Blob) as language06, ; >*!* CAST(STRCONV(language07,16) as Blob) as language07, ; >*!* CAST(STRCONV(language08,16) as Blob) as language08, ; >*!* CAST(STRCONV(language09,16) as Blob) as language09, ; >*!* CAST(STRCONV(language10,16) as Blob) as language10, ; >*!* lngImage00, ; >*!* lngImage01, lngImage02, lngImage03, lngImage04, lngImage05, ; >*!* lngImage06, lngImage07, lngImage08, lngImage09, lngImage10 ; >*!* from csrPrefs_sl into cursor prefs_sl readwrite >SELECT prefs_sl>
>lparameters tLanguageField >this.LanguageField = tLanguageField >this.lblLanguage.caption = this.lblLanguage.caption + ' ' + transform(val(right(tLanguageField,2))) >this.txtLanguage.text = CAST(STRCONV(evaluate(tLanguageField),16) as Blob) >>
>IF thisform.IsChanged > local utf8, utf16Out > utf8 = this.Text > = StringUtf8ToUTF16(@m.utf16Out, m.utf8) > > replace (this.Parent.LanguageField) WITH strconv(utf16Out, 15) >endif>
>IF THISFORM.IsChanged > LOCAL lcSQL > TEXT TO lcSQL noshow > UPDATE dbo.prefs_sl > SET defltlang = ?prefs_sl.DefltLang, > language00 = cast(?prefs_sl.language00 as nvarchar(100)), > lngimage00 = ?prefs_sl.lngimage00, > language01 = cast(?prefs_sl.language01 as nvarchar(100)), > lngimage01 = ?prefs_sl.lngimage01, > language02 = cast(?prefs_sl.language02 as nvarchar(100)), > lngimage02 = ?prefs_sl.lngimage02, > language03 = cast(?prefs_sl.language03 as nvarchar(100)), > lngimage03 = ?prefs_sl.lngimage03, > language04 = cast(?prefs_sl.language03 as nvarchar(100)), > lngimage04 = ?prefs_sl.lngimage04, > language05 = cast(?prefs_sl.language05 as nvarchar(100)), > lngimage05 = ?prefs_sl.lngimage05, > language06 = cast(?prefs_sl.language06 as nvarchar(100)), > lngimage06 = ?prefs_sl.lngimage06, > language07 = cast(?prefs_sl.language07 as nvarchar(100)), > lngimage07 = ?prefs_sl.lngimage07, > language08 = cast(?prefs_sl.language08 as nvarchar(100)), > lngimage08 = ?prefs_sl.lngimage08, > language09 = cast(?prefs_sl.language09 as nvarchar(100)), > lngimage09 = ?prefs_sl.lngimage09, > language10 = cast(?prefs_sl.language10 as nvarchar(100)), > lngimage10 = ?prefs_sl.lngimage10 > where pri_key = ?prefs_sl.pri_key > ENDTEXT > RETURN mySQLExec(m.lcSQL, '',PROGRAM()) >ENDIF >>