Unicode in Fields

  • V6.04

    We have the problem that unicode characters in fields (source) get lost after a write/read cycle

    In the text everythings is alright with €, in the fields the get replaced by a
    mathematical not sign

    chuck

  • it seems, that the € gets lost in loading the RTF

    this is the file after saving it:

    ---------------------------------------

    {\rtf1\ansi\deff0\uc1\ansicpg1252\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;}\landscape\wpprheadfoot1\paperw16838\paperh11906\margl1417\margr1417\margt1417\margb1440\headery720\footery720\endnhere\sectdefaultcl{\*\generator WPTools_6.030;}{\plain\fs30\cf1\b\u8364 ?\u8364 ?\u8364 ?\u8364 ?\u8364 ?\u8364 ?\u8364 ?\u8364 ?\par
    \pard\plain\plain\fs30\cf3\b\par
    \plain\fs30\cf3\b{\field{\*\fldinst{MERGEFIELD FF12 <TI ID="50107" l="0" ><rd><redir t="Lnk" /></rd><Ps><P n="1" ><v t="s">/T=XXX</v></P><P n="2" ><v t="s">gleich</v></P><P n="3" ><v t="s">/T=XXX</v></P><P n="4" ><v t="s">¬</v></P><P n="5" ><v t="s">EURO</v></P></Ps></TI>}}{\*\wpfldparam{IIF}}{\fldrslt{IIF\wpiparam107}}}\par
    \pard\plain\plain\fs30\cf3\b\par
    \plain\fs30\cf3\b\wpiparam107{\field{\*\fldinst{MERGEFIELD FF13 <TI ID="50105" l="0" ><rd><redir t="DB" /></rd><Ps><P n="1" ><v t="s">\u8364 €\u8364 €\u8364 €\u8364 €\u8364 €\u8364 €\u8364 €\u8364 €</v></P></Ps></TI>}}{\*\wpfldparam{/T}}{\fldrslt{/T}}}\par
    \pard\plain\plain\fs22\par
    \plain\fs22 -----\par
    \plain\fs22 x{\field{\*\fldinst{MERGEFIELD FF11 <TI ID="3123" l="0" ><rd><redir t="Obj" /><redir t="Ctl" /><redir t="Ct" /><redir t="Obj" /></rd><Ps></Ps></TI>}}{\*\wpfldparam{Adress}}{\fldrslt{Adress\wpiparam107}}}x\par
    \plain\fs22 ----\par
    }}

    -------------------------------------------------

    perhaps this helps to find the solution

  • I did some further investigating with this issue.

    It seems that the not sign arises in WPIOReadRTF in AppendChar, being a subroutine of TWPRTFReader.Parse

    Code
    if FStack.Destination = rdsFieldStringBuilder thenbegin   if FStringBuilder <> nil then begin      FStringBuilder.AppendChar(AnsiChar(aCh));   end;

    Casting aCh to AnsiChar (3864) results in Char(172) being ¬

    I get the correct output if I replace it with these lines:

    Code
    if FStack.Destination = rdsFieldStringBuilder then
    begin
       if FStringBuilder <> nil then begin
          if isUnicode then begin
              FStringBuilder.Append(Char(aCh));
          end else
              FStringBuilder.AppendChar(AnsiChar(aCH));
       end;