Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Working with Russian text in VFP
Message
De
11/04/2006 11:18:37
 
 
À
10/04/2006 13:12:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Divers
Thread ID:
01110111
Message ID:
01112437
Vues:
234
Anton,

AWESOME! THANK YOU!!!

For those following this thread, there are 3 steps necessary to come up with a complete solution.

1. Anton's corrections to my original code. Anton's code demonstrates how to successfully convert content coming in from UTF8 and Unicode formats.

Anoton's fixes resulted in visually identical text displays that were obviously in another language but that still did not display in a non-Cyrillic font on my US version of XP Pro.

Here's the correct code, courtesy of Anton.
lcUtf8 = filetostr( 'russian_utf8.txt' )
lcRussian = strconv( lcUtf8, 11, 1251, 1 )
strtofile( lcRussian, 'russian.txt' )
modify file russian.txt as 1251 

lcUnicode = filetostr( 'russian_unicode.txt' )
lcRussian = strconv( lcUnicode, 6, 1251, 1 )
strtofile( lcRussian, 'russian.txt' )
modify file russian.txt as 1251 
2. To get Anton's code to display in a Cyrillic font, I used a tip from Rick Strahl's article (URL below) which explains that one must choose a language that Windows will use when displaying non-Unicode text. Unfortunately you can only choose *ONE* language for Windows to use (in addition to English?). Using the path below, I changed my non-Unicode language to Russian, made sure code page 1251 was enabled on my workstation (from the list below the non-Unicode language) and then performed the required *REBOOT* of my workstation. BTW: 1251 was enabled by default on my US version of XP Pro.

Under XP Pro, this is the path to select Russian as your non-Unicode language of choice:

Control Panel/Regional and Language Options/Advanced/Language for non-Unicode Programs/Russian

After changing my non-Unicode language to Russian, rebooting my workstation, and running Anton's code, VOLIA! Russian text displayed perfectly in VFP when I specifically use AS 1251 to control codepage mapping. Interestingly, the "AS 1251" codepage reference does not appear to be needed as the text displayed correctly in my environment with and without this clause in my MODIFY FILE command.

Here's the link to Rick's article that offers more background on using VFP with a non-Unicode language (plus a lot of other great ideas for working with Unicode and multiple lanaguages in VFP)

http://www.west-wind.com/presentations/foxunicode/foxunicode.asp

3. The final step was to use Anton's tip regarding the mysterious "?" that shows up as the first character of Unicode text translated via VFP's strconv() function.

Quoting Anton:


Something you can also add is to remove first 2 bytes from UTF-8 and Unicode texts. AFAIK they are some kind of header, not a character. So, the first character in lcRussian is stupid question mark in both cases.


So it appears that one should wrap UTF8/Unicode strconv() expressions with code to remove the first character.

Malcolm
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform