This is probably us misusing the component, but when we merge national text (Japanese) into a WPRichEdit and then save the memo to an RTF file, the memo does not encode the CP932 text in the normal RTF way, using escape codes and hex. Is there a specific requirement for this to work?
Merge fields / codepages
-
-
- Offizieller Beitrag
Hi,
You can specify a codepage when saving: RTF-codepagexxxx. But in general all characters above $A0 are encoded as unicodes, \u which is RTF conform.
Julian
-
Well, that didn't help, for some reason WPRichEdit is not encoding the text, see the example below (original file). Notice that the Japanese text is not encoded and while it looks OK when looking at the RTF in notepad, it shows as mojibake in wordpad etc
Code
Alles anzeigen{\rtf1\ansi\deff0\uc1\ansicpg932\deftab720{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery254\footery254\endnhere\sectdefaultcl{\*\generator WPTools_5.500;}{\plain\fs32\cf3 This is the new (UK) mail to accounts template.\par \plain\fs32\cf3 Applicant\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD APPLICANT}}{\*\wpfldparam{APPLICANT}}{\fldrslt{Christian Mague}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 Duration\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD DURATION}}{\*\wpfldparam{DURATION}}{\fldrslt{長期}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 Start Date End Date\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD START_DATE}}{\*\wpfldparam{START_DATE}}{\fldrslt{18-10-2004}}} to {\field{\*\fldinst{MERGEFIELD END_DATE}}{\*\wpfldparam{END_DATE}}{\fldrslt{29-3-2010}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 Pay:PAY\par \plain\fs32\cf3 Charge:{\field{\*\fldinst{MERGEFIELD CHARGE}}{\*\wpfldparam{CHARGE}}{\fldrslt{Fee : 25.00%}}}\par \plain\fs32\cf3 Profit:{\field{\*\fldinst{MERGEFIELD PROFIT}}{\*\wpfldparam{PROFIT}}{\fldrslt{3125000.00}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 EXP_DURATE: {\field{\*\fldinst{MERGEFIELD EXP_DURATE}}{\*\wpfldparam{EXP_DURATE}}{\fldrslt{長期}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD COMPANY}}{\*\wpfldparam{COMPANY}}{\fldrslt{Morgan Stanley}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD COMPANY_ADDRESS}}{\*\wpfldparam{COMPANY_ADDRESS}}{\fldrslt{}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD CONTACT}}{\*\wpfldparam{CONTACT}}{\fldrslt{Y. Hamasaki}}}\par \pard\plain\plain\fs32\cf3\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 invoice details:\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD INVOICE_ADDRESS}}{\*\wpfldparam{INVOICE_ADDRESS}}{\fldrslt{スタヴァンゲルはノルウェーの都市。ローガラン県の県都。人口は約11万2千人。}}}\par \pard\plain\plain\fs32\cf3\par \pard\plain\plain\fs32\cf3\par }}
-
- Offizieller Beitrag
Does it look ok in Word and WPTools ?
Maybe you can send the orginal file in WPT format.
Julian
-
The RTF actually does look OK in the WPTools MultiDemo and in Wordpad (in contradiction to what I said before) but in Word (2007 & 2010 at least) it does not appear correctly. If I open this WPT file in the multi demo and then save it as an RTF it does the same thing and saves it without encoding.
-
- Offizieller Beitrag
Hi,
I tried it here and get this - it loads as expected in Word. (V6.10)
Code
Alles anzeigen{\rtf1\ansi\deff0\uc1\ansicpg1252\deftab720{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}{\f2\fnil\fcharset2 Symbol;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\ red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\ wpprheadfoot1\paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\headery254\footery254\ftnbj\sftnbj\sftnrstcont\nocolbal\sftnnar\saftnnar\fet0\endnhere\sectdefaultcl{\*\generator WPTools_6.060-PRM;}{\plain\fs32\cf3 This is the new (UK) mail to accounts template.\par \plain\fs32\cf3 Applicant\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD APPLICANT}}{\*\wpfldparam{APPLICANT}}{\fldrslt{Christian Mague}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 Duration\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD DURATION}}{\*\wpfldparam{DURATION}}{\fldrslt{\u38263 ?\u26399 ?}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 Start Date End Date\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD START_DATE}}{\*\wpfldparam{START_DATE}}{\fldrslt{18-Oct-2004}}} to {\field{\*\fldinst{MERGEFIELD END_DATE}}{\*\wpfldparam{END_DATE}}{\fldrslt{30-Mar-2010}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 Pay:PAY\par \plain\fs32\cf3 Charge:{\field{\*\fldinst{MERGEFIELD CHARGE}}{\*\wpfldparam{CHARGE}}{\fldrslt{Fee : 25.00%}}}\par \plain\fs32\cf3 Profit:{\field{\*\fldinst{MERGEFIELD PROFIT}}{\*\wpfldparam{PROFIT}}{\fldrslt{3125000.00}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 EXP_DURATE: {\field{\*\fldinst{MERGEFIELD EXP_DURATE}}{\*\wpfldparam{EXP_DURATE}}{\fldrslt{\u38263 ?\u26399 ?}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD COMPANY}}{\*\wpfldparam{COMPANY}}{\fldrslt{Morgan Stanley}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD COMPANY_ADDRESS}}{\*\wpfldparam{COMPANY_ADDRESS}}{\fldrslt{}}}\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD CONTACT}}{\*\wpfldparam{CONTACT}}{\fldrslt{Y. Hamasaki}}}\par \pard\plain\plain\fs32\cf3\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3 invoice details:\par \pard\plain\plain\fs32\cf3\par \plain\fs32\cf3{\field{\*\fldinst{MERGEFIELD INVOICE_ADDRESS}}{\*\wpfldparam{INVOICE_ADDRESS}}{\fldrslt{\u12473 ?\u12479 ?\u12532 ?\u12449 ?\u12531 ?\u12466 ?\u12523 ?\u12399 ?\u12494 ?\u12523 ?\u12454 ?\u12455 ?\u12540 ?\u12398 ?\u37117 ?\u24066 ?\u12290 ?\u12525 ?\u12540 ?\u12460 ?\u12521 ?\u12531 ?\u30476 ?\u12398 ?\u30476 ?\u37117 ?\u12290 ?\u20154 ?\u21475 ?\u12399 ?\u32004 ?11\u19975 ?2\u21315 ?\u20154 ?\u12290 ?}}}\par \pard\plain\plain\fs32\cf3\par \pard\plain\plain\fs32\cf3\par }}
-
OK, it turns out that the reason it wasn't encoding the text is because my system locale (Language for non-Unicode programs) was set to Japanese (Japan). When I changed this back to English (United Kingdom) and rebooted it did start encoding the text correctly. This is not the correct behaviour, I would argue; the text should always be encoded regardless of the system locale.
-
So... um is this going to be fixed? Do you have any idea when? Or, shall I suggest they abandon the whole IT thing and use a paper and pen???
-
- Offizieller Beitrag
Hi,
2 Byte Unicode is not able to distinguish between Japanese, Cuinese and Korean. The characters are close but not the same. This is why You need a system locale to let the system display the correct characters.
In WPTools You can assing a characterset to the text - this helps to give the system a hint which charac ter to select and display.
To assign a character set use CurrAttr.CharSet
JUlian
-
The problem is that WPTools, has a bug where when the system locale is set to Japanese it does not encode CJK text with hex codes when saving to RTF. Presumably WPTools is comparing the current system locale to GetACP or CP_ACP under the assumption that this refers to 1252 or something along those lines.
But, to be clear, the problem is that WPTools produces corrupt RTF files when those files contain CJK text and are on a Japanese (and presumably others) system locale.
As this is a bug, an idea on when it will be fixed would be great!
-
- Offizieller Beitrag
Please lokate this lien in WPIOWriteRTF
if OptCodePage <> 1252 then // Save using codepage ?
and change it to
if false then // Save using codepage ?
It should then create the unitcode values.
Julian
-
This works, thanks.
Am I right in thinking this was bug, specifically will this change be made in the next release?