Closed Bug 15706 Opened 25 years ago Closed 25 years ago

Unicode Encoder: inconsistent unichar length returned in case of the error code is NS_ERROR_UENC_NOMAPPING

Categories

(Core :: Internationalization, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: nhottanscp, Assigned: cata)

Details

Using the encoder to convert from unicode, I get different numbers for consumed
unichar length in case of the no mapping error.

Here is my test case. I used an input string "\x61\x62\x80\xA0\x63" with
ISO-8859-1 and ISO-2022-JP encoders. '\x80' causes no mapping error for both
charsets.
The results I got were.
ISO-8859-1: aSrcLength was 3 and aDestLength was 2
ISO-2022-JP: aSrcLength was 2 and aDestLength was 2
Blocks: 8865
Status: NEW → ASSIGNED
Target Milestone: M12
My bug 8865 depends on this. 8865 is M11 and depended by four other bugs.
Cata, do you have any idea of what is wrong, any estimation of the cost?
This is first on my list for Monday. Hopefully I'll have a fix for Tuesday.
This is the diff for the fix. I am testing it right now. To be in when I'm
certain it works.

S:\mozilla\intl\uconv\ucvja>cvs diff -c nsUnicodeToISO2022JP.cpp
Index: nsUnicodeToISO2022JP.cpp
===================================================================
RCS file: /cvsroot/mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp,v
retrieving revision 1.1
diff -c -r1.1 nsUnicodeToISO2022JP.cpp
*** nsUnicodeToISO2022JP.cpp    1999/08/03 18:02:58     1.1
--- nsUnicodeToISO2022JP.cpp    1999/10/22 22:38:22
***************
*** 190,196 ****
      dest += bcw;

      if ((res != NS_OK) && (res != NS_ERROR_UENC_NOMAPPING)) break;
-     if (res == NS_ERROR_UENC_NOMAPPING) src--;
    }

    *aSrcLength = src - aSrc;
--- 190,195 ----
No longer blocks: 8865
Ok, an updated fix that solves the infinite loop problem when returning 0 in the
case when fist char is unmappable. Naoki, please review and let me know if it
works for you. Thanks!

S:\mozilla\intl\uconv\ucvja>cvs diff -c nsUnicodeToISO2022JP.cpp
Index: nsUnicodeToISO2022JP.cpp
===================================================================
RCS file: /cvsroot/mozilla/intl/uconv/ucvja/nsUnicodeToISO2022JP.cpp,v
retrieving revision 1.1
diff -c -r1.1 nsUnicodeToISO2022JP.cpp
*** nsUnicodeToISO2022JP.cpp    1999/08/03 18:02:58     1.1
--- nsUnicodeToISO2022JP.cpp    1999/10/27 22:42:54
***************
*** 173,179 ****
        if (res != NS_ERROR_UENC_NOMAPPING) break;
      }

!     if (i>=4) res = NS_ERROR_UENC_NOMAPPING;
      if (res != NS_OK) break;

      bcw = destEnd - dest;
--- 173,182 ----
        if (res != NS_ERROR_UENC_NOMAPPING) break;
      }

!     if (i>=4) {
!       res = NS_ERROR_UENC_NOMAPPING;
!       src++;
!     }
      if (res != NS_OK) break;

      bcw = destEnd - dest;
***************
*** 190,196 ****
      dest += bcw;

      if ((res != NS_OK) && (res != NS_ERROR_UENC_NOMAPPING)) break;
-     if (res == NS_ERROR_UENC_NOMAPPING) src--;
    }

    *aSrcLength = src - aSrc;
--- 193,198 ----
Blocks: 17432
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Status: RESOLVED → REOPENED
Status: REOPENED → RESOLVED
Closed: 25 years ago25 years ago
Target Milestone: M12 → M11
QA Contact: teruko → nhotta
Changed QA contact to nhotta.
Status: RESOLVED → VERIFIED
The problem does not happen anymore.
No longer blocks: 17432
You need to log in before you can comment on or make changes to this bug.