Closed
Bug 238445
Opened 20 years ago
Closed 20 years ago
Can't save page as file with chinese filename
Categories
(Core :: Internationalization, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: ccwu, Assigned: mkaply)
Details
Attachments
(1 file, 2 obsolete files)
4.53 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (OS/2; U; Warp 4.5; en-US; rv:1.7a) Gecko/20040225 Build Identifier: Mozilla/5.0 (OS/2; U; Warp 4.5; en-US; rv:1.7a) Gecko/20040225 Can't save page as file with chinese filename Reproducible: Always Steps to Reproduce: 1.Open one page 2.Click File->Save Page As 3.Add any Chinese character to filename 4.Click Save 5.The dialog was closed and nothing happened
Assignee: file-handling → smontagu
Component: File Handling → Internationalization
QA Contact: ian → amyy
Assignee | ||
Comment 1•20 years ago
|
||
I have no idea how this one has existed so long. Problem is here: http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsNativeCharsetUtils.cpp#1019 resultLen must be more than inputLen, since inputLen is number of unicode chars and we could have more native chars than we had unicode. Working on a solution.
Assignee: smontagu → mkaply
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee | ||
Comment 2•20 years ago
|
||
Buffer for conversion needs to be twice as many chars as the unicode string since one unicode char can become two platform bytes.
Updated•20 years ago
|
Attachment #144753 -
Flags: review+
Comment 3•20 years ago
|
||
Comment on attachment 144753 [details] [diff] [review] Fix for problem > + size_t inputLen = (flat.Length()*2) + 1; // include null char Please make that + size_t inputLen = (flat.Length()*sizeof(PRUnichar)) + 1; // include null char
Assignee | ||
Comment 4•20 years ago
|
||
I didn't mean sizeof(PRUnichar), I meant two. The issue here is converting from Unicode to a native charset. the sizeof PRUnichar is irrelvant. When x number of unicode characters is converted to a native character set (not UTF-8 or GB18030), the maximum number of chars that can result is x*2. It has nothing to do with the size of a PRUnichar.
Assignee | ||
Comment 5•20 years ago
|
||
Fix checked in.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Comment 6•20 years ago
|
||
Michael Kaply wrote:
> When x number of unicode characters is converted to a native character set
> (not UTF-8 or GB18030), the maximum number of chars that can result is x*2.
> It has nothing to do with the size of a PRUnichar.
Ouch... you're right... I didn't saw that from the patch, only from looking at
the original source...
Comment 7•20 years ago
|
||
The patch is not quite right. The length of the resulting string is too long.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 8•20 years ago
|
||
The inputLen should not be set to length*2+1. We were converting twice as much data.
Attachment #144753 -
Attachment is obsolete: true
Comment 9•20 years ago
|
||
Oops, removed too many comments. Also, we don't need to worry about the terminating null.
Attachment #144797 -
Attachment is obsolete: true
Updated•20 years ago
|
Attachment #144801 -
Flags: review?(mkaply)
Comment 10•20 years ago
|
||
(In reply to comment #4) > When x number of unicode characters is converted to a native character set (not > UTF-8 or GB18030), the maximum number of chars that can result is x*2. It's probably true on OS/2, but it's not always the case in general. In addition to GB18030, EUC-JP, EUC-KR and EUC-TW need more than two bytes for some Unicode characters.
Assignee | ||
Comment 11•20 years ago
|
||
The new patch has been checked in to trunk and 1.4
Status: REOPENED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•20 years ago
|
Attachment #144801 -
Flags: review?(mkaply)
You need to log in
before you can comment on or make changes to this bug.
Description
•