problem when using Chinese

  • hello, i am new to Wptools, I downloaded the demo from your website, and ran the demo "WPMultiDemo.exe". when I typed western characters, it ran very smoothly, but when i typed Chinese characters in it, some problems occured. I couldn't use arrow keys, delete key and backspace key in editor. for example, when i pressed left arrow, the cursor didn't move to previous position. Exactly in fact, the cursor moved, but after i pressed 12 times of left arrow, yes , exactly 12 times. the same as right arrow key,backspace and delete.
    how can i resolve this problem?
    thanks.

    • Offizieller Beitrag

    Hi,

    I am a bit surprised that this does not work. The text is internally stored in WideChars - so with simplified chinese one char shoule be one wide char (am I correct ?) So cursor movement should work, too.

    Maybe there is a setting which creates multiple characters instead of one in the editor -

    In my tests (with XP + Chinese pack) it worked so far - although I have to say that WPTools does not respect any chinese or japanese word break rukles and justified text is also not possible.

    Julian

  • it works in strange way. if i load a rtf file to wptools, it works good, i can move the cursor back and forward, and i can delete by delete key or backspace. but i when i type new Chinese characters in this document, the cursor can't move between new-typed characters, but can move between former loaded characters.

    in other condition, if i copy some text from other plain text editor(i.e. notepad, delphi ide), and paste to wptools, they will be unrecognized, same as i copy text from Internet Explorer to wptools. But if i copy text from Microsoft Word, and paste to wptools, it works well. the same is when i copy text from wptools to other editors.

    i think perhaps because microsoft word stores text as unicode and others store as gb2312 charset.

    as you have said in other posts, wptools supports DBCS, but not particular to simpified Chinese, traditional C.hinese or Japanese. do you think these problems can't be solved?

    • Offizieller Beitrag

    Hi,

    >>i think perhaps because microsoft word stores text as unicode and others store as gb2312 charset. <<

    Yes, I think this is the difference. But WPTools cannot recognize ANSI text in the clipboard to be gb2312 . It will however use unicode if there is unicode in the clipboard.

    When you type it is possible that simply the current codepage is not know. Internally this code should be called to regnice the codepage:

    function TWPRTFEnginePaint.UpdateCodePage: Integer;
    var
    LocaleInfo: string;
    LocaleInfoLen, n: Integer;
    LocaleID: Cardinal;
    begin
    LocaleID := GetKeyboardLayout(0) and $FFFF;
    LocaleInfoLen := GetLocaleInfo(LocaleID, $00001004, nil, 0);
    SetLength(LocaleInfo, LocaleInfoLen);
    GetLocaleInfo(LocaleID, $00001004, PChar(LocaleInfo), LocaleInfoLen);
    n := StrToIntDef(LocaleInfo, GetACP);

    if n <> _CodePage then
    begin
    _CodePage := n;
    _CharSet := WPGetCharSet(_CodePage);
    if _CharSet < 0 then
    _CharSet := DEFAULT_CHARSET;
    end;
    Result := _CodePage;
    end;

    The codepage is then used for the entered chracters to be converted to unicode.

    >>as you have said in other posts, wptools supports DBCS, but not particular to simpified Chinese, traditional C.hinese or Japanese. do you think these problems can't be solved?<<

    DBCS is not supported, this was in version 4. WPTools 5 only uses DBCS when reading RTF files. The DBCS code is translated to unicode.

    Julian

  • would you please send me an email with a compiled example of this case? i am evaluating wptools, it seems very good but Chinese is not supported very well. thanks. i think you can see my email address in my profile.