Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Further discussion: VFP, XML data and Excel
Message
From
22/01/2007 12:01:36
 
 
To
09/01/2007 11:41:15
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01183825
Message ID:
01187732
Views:
49
This message has been marked as the solution to the initial question of the thread.
Heya all,

I think I took a wrong turn when looking for a solution to this problem. We've found out a very simple solution that it was so glaringly obvious we missed it. Here is how we solved it:

1. Use the desired codepage for each table (ie. 1251 is russian)
2. Set the desired codepage in the CONFIG.FPW (CODEPAGE=1251)
3. Set the desired application FontCharSet (ie. 204 is russian)
4. Then STRTOFILE(rawdata) to XML. So why does it work now?
This is the catch. In the xml tag, add the "encoding" attribute. Very important! the attribute "encoding" is case-sensitive and should be in all lowercase.
<?xml version="1.0" encoding="WINDOWS-1252"?> && works with Spanish accented chars
<?xml version="1.0" encoding="WINDOWS-1251"?> && works with Russian chars
<?xml version="1.0" encoding="WINDOWS-1254"?> && works with Turkish chars
Another important note: You still have to translate the "&" character in the data to its numerical code. I didn't test for the other 3 but I translated them just in case. Remember, there are no spaces in the numerical code - I placed them there so the web brower will not translate them.
xmlText = strtran(xmlText, '&', '& # 3 8 ;') && ampersand
xmlText = strtran(xmlText, '?', '& # 6 3 ;') && question mark
xmlText = strtran(xmlText, '%', '& # 3 7 ;') && percent symbol
xmlText = strtran(xmlText, "'", '& # 3 9 ;') && apostrophe
I hope this will help others in the future.

>Hi all,
>
>I posted this problem and found a solution to it by using CONFIG.FPW with the proper CODEPAGE setting in it.
>
>Problem: We have a program that creates an XML file output. As such, international characters have to be transformed to its equivalent in &#xxx; format. We hard-code each character that we wanted to transform. However, the more complex characters like Й (cyrillic) or Ğ (turkish) doesn't show properly in the Visual FoxPro editor. The formatting code looks like this:
>
>xmlText = strtran(xmlText, 'ç', 'ç') && small c with cedilla
>*edited: UT converted the code; the 3rd parameter is "& # 2 3 1 ;" without the spaces.
>
>I cannot type in the two characters listed above in the second parameter of the strtran() function inside the Visual FoxPro editor. I've tried setting: _screen.FontCharSet = 162 for Turkish and 204 for Russian and used the Windows On-Screen keyboard to type it in but the literal text Й (cyrillic) or Ğ (turkish) does not display properly.

>
>Or so I thought. While this works without problem when run from the VFP IDE, I get the same error when running it from an executable. The program actually does more than create the XML. It also opens up Excel using a template and import in the XML data. The merging of the XML data is where the problem is. Where before, it had to do with the actual data, now its when I run the program from an executable.
ramil
~~ learning to stand still
Previous
Reply
Map
View

Click here to load this message in the networking platform