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

VERIFIED FIXED in M11

Status

()

Core
Internationalization
P3
normal
VERIFIED FIXED
19 years ago
19 years ago

People

(Reporter: nhottanscp, Assigned: cata)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

19 years ago
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
(Reporter)

Updated

19 years ago
Blocks: 8865
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
Target Milestone: M12
(Reporter)

Comment 1

19 years ago
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?
(Assignee)

Comment 2

19 years ago
This is first on my list for Monday. Hopefully I'll have a fix for Tuesday.
(Assignee)

Comment 3

19 years ago
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 ----
(Reporter)

Updated

19 years ago
No longer blocks: 8865
(Assignee)

Comment 4

19 years ago
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 ----

Updated

19 years ago
Blocks: 17432
(Assignee)

Updated

19 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED
(Assignee)

Updated

19 years ago
Status: RESOLVED → REOPENED
(Assignee)

Updated

19 years ago
Status: REOPENED → RESOLVED
Last Resolved: 19 years ago19 years ago
Target Milestone: M12 → M11

Updated

19 years ago
QA Contact: teruko → nhotta

Comment 5

19 years ago
Changed QA contact to nhotta.
(Reporter)

Updated

19 years ago
Status: RESOLVED → VERIFIED
(Reporter)

Comment 6

19 years ago
The problem does not happen anymore.

Updated

18 years ago
No longer blocks: 17432
You need to log in before you can comment on or make changes to this bug.