function StrToNchar( lcStr ) local lcRetVal, i, lnLen lcRetVal = "" lnLen = len( lcStr ) if ( lnLen % 2 = 1 ) * unicode strings must have lengths that are divisible by 2 * pad this out with a null character lcStr = lcStr + chr( 0 ) endif for i = 1 to lnLen step 2 lcRetVal = lcRetVal + "+nchar(" + transform( asc( substr( lcStr, i+1, 1 ) ) * 256 + asc( substr( lcStr, i, 1 ) ) ) + ")" endfor if ( lnLen > 0 ) lcRetval = substr( lcRetVal, 2 ) endif return lcRetValala:
select testthis scan for "descript" $ lower( name ) SQLExec( gnSQLConnection, "insert into testunicode ( descript ) values (" + ; StrToNchar( strconv( testthis.value, 12 ) ) + ")" ) endscanIn the above code testthis.descript was UTF8 data coming from an ADO recordset off an ASP page.