#848 SysFromUnicode does not work well again in the release 4.0.0

v4.0.1
closed
Mark Miesfeld
APIs (66)
5
2012-08-14
2009-10-14
Kat Masuda
No

When the target codepage is UTF8, the SysFromUnicode function terminated with the return code
- 87, when no mapping flags
- 1004, when any combination of the supported flags.
The function work well in the R3 (I am not sure the specific release#. maybe R320?).
There seems to have been a fixed defect (ID: 1440558) similar to mine in R3.
Ref: The bug in R3 (https://sourceforge.net/tracker/index.php?func=detail&aid=1440558&group_id=119701&atid=684730)

Discussion

  • Mark Miesfeld
    Mark Miesfeld
    2009-10-14

    Please attach a working example program that demonstrates the bug.

    SysFromUnicode() essentially just invokes the operating system function WideCharToMultiByte(). The errors you report come from the operating system.

    Microsoft provides, free of charge, good documentation in the MSDN library. Use a Google search of: MSDN WideCharToMultiByte

    Be sure to use the link that reads: WideCharToMultiByte Function (Windows)

    not the link that reads: WideCharToMultiByte (Windows CE 3.0)

    The errors you report are:

    ERROR_INVALID_PARAMETER 87 The parameter is incorrect.

    and

    ERROR_INVALID_FLAGS 1004 Invalid flags.

    In ooRexx 4.0.0 the docs in the RexxUtils section have been updated to show you how to decipher the Windows system error codes and how to find the MSDN documentation.

    If you provide a working program I'll look further into this.

     
  • Mark Miesfeld
    Mark Miesfeld
    2009-10-14

    Okay, there is definitely a bug here when using UTF8.

    Internally:

    With UTF8, lpDefaultChar and lpUsedDefaultChar both have to be set to NULL. However, the code always sets those 2 paramaters. That produces ERROR_INVALID_PARAMETER. So, SysFromUnicode(), with UTF8, can never work.

    Again, with UTF8, dwFlags has to be 0, or on Vista only, it can be WC_ERR_INVALID_CHARS. Since the code doesn't support WC_ERR_INVALID_CHARS, using any flags with UTF8 will always produce ERROR_INVALID_FLAGS.

    I still need a working program that I can use to test with.

     
  • Kat Masuda
    Kat Masuda
    2009-10-15

    Thanks for your quick reply.
    I uploaded a sample test case for you to reproduce the isue.

    Regards,

     
  • Mark Miesfeld
    Mark Miesfeld
    2009-10-15

    Committed revision 5260.

    Your test passes after this commit.

    In addition, I used this program to test:

    / /
    parse Version V; say V

    string = "Hello World"
    rc = SysToUnicode(string, 'UTF8', ,Out.)
    say 'SysToUnicode() UTF8 rc:' rc
    if rc == 0 then do
    say 'c2x:' c2x(Out.!text)
    say 'txt:' Out.!text
    end
    say

    rc = SysFromUnicode(Out.!text,'UTF8',,,Out.)
    say 'SysFromUnicode() UTF8 rc:' rc
    if rc == 0 then do
    say 'txt:' Out.!text
    say 'c2x:' c2x(Out.!text)
    end

    With the 4.0.0 release I get this output:

    C:\work.ooRexx\ooTest\4.x>unicodeTest.rex
    REXX-ooRexx_4.0.0(MT) 6.03 15 Aug 2009
    SysToUnicode() UTF8 rc: 0
    c2x: 480065006C006C006F00200057006F0072006C006400
    txt: H e l l o W o r l d

    SysFromUnicode() UTF8 rc: 87

    C:\work.ooRexx\ooTest\4.x>

    Which demonstrates the bug you reported.

    After the fix I committed I get this output:

    C:\work.ooRexx\ooTest\4.x>unicodeTest.rex
    REXX-ooRexx_4.0.0(MT) 6.03 14 Oct 2009
    SysToUnicode() UTF8 rc: 0
    c2x: 480065006C006C006F00200057006F0072006C006400
    txt: H e l l o W o r l d

    SysFromUnicode() UTF8 rc: 0
    txt: Hello World
    c2x: 48656C6C6F20576F726C64

    C:\work.ooRexx\ooTest\4.x>

     


Anonymous


Cancel   Add attachments