Merge fields / codepages

  • 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?

  • 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

  • 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)

  • 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.

    • 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!