Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to asign a variable with unicode value?

Status
Not open for further replies.

wcglorioso

Programmer
Jul 23, 2003
30
0
0
PH
Hi everyone,

I stumbled into a Java Script program which I want to reprogram in VFP.

It had an array constant populated with some unicode characters.

I would like to know how I would do it in VFP.

I cant seem to figure out how to use the function strconv() for this purpose.

True, the documentation says it can convert double-byte characters to UNICODE (wide characters) but how do I produce a double-byte character to convert to UNICODE?

The chr() function deals with only single-byte characters.

Certainly, the str() function will not do.

How do we go about generating a UNICODE character for assignment to an array element then?

Thanks in advance for any help.
 
This is a two-stage proces. You first need to convert from Unicode to Double Byte Character Set (DBCS), using STRCONV() with the second parameter set to 6. Then call STRCONV() again, with the second param set to 2 to convert DBCS to single byte. For this second step, you also need to specify the locale.

That said, I have to say that I have neve managed get this to work properly. VFP's native support for Unicode is pretty non-existent. You might be better off writing (or finding) a DLL or other component in another language, and calling it from your VFP code.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks Mike for the information.

What I like to know now is how do I generate a DBCS that I can convert to UNICODE.

I just like to produce UNICODE characters for assignment into a variable.

I do not intend to convert FROM UNICODE but to convert TO UNICODE.

But as you said, it may not be possible.

May just go for writing a DLL in a language that suppports UNICODE if the UNICODE generation is not possible.

Thanks again.
 
wcglorioso,

Sorry, I mis-read your original question. I see now that you want to convert to Unicode.

I don't think this is possible in VFP. In theory, you can call STRCONV() with the second param set to 5, but it doesn't seem to work -- you just get your original string in double-byte characters, not Unicode.

Unless anyone else knows a solution, I think writing the DLL might be your best bet.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top