Closed Bug 936439 Opened 13 years ago Closed 12 years ago

EncodingUtils should have a method for asking if a string is an encoding that FindEncodingForLabel could return

Categories

(Core :: Internationalization, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: hsivonen, Assigned: hsivonen)

Details

Attachments

(1 file)

I need this for implementing the replacement encoding.
Attached patch Add IsEncoding — — Splinter Review
Despite the comment, this isn't #ifdef DEBUG, because I have one non-DEBUG use case.
Attachment #829217 - Flags: review?(VYV03354)
Comment on attachment 829217 [details] [diff] [review] Add IsEncoding >+ // Using labelsEncodings isn't as efficient as possible, but this is mostly >+ // used for debug build asserts anyway. What is the non-DEBUG use case do you have? Is this acceptable to it? How about nsCString label(aEncoding); ToLowerCase(label); return NS_SUCCEEDED(nsUConvPropertySearch::SearchPropertyValue( labelsEncodings, ArrayLength(labelsEncodings), label, enc)) && aEncoding.Equals(enc); ?
(In reply to Masatoshi Kimura [:emk] from comment #2) > Comment on attachment 829217 [details] [diff] [review] > Add IsEncoding > > >+ // Using labelsEncodings isn't as efficient as possible, but this is mostly > >+ // used for debug build asserts anyway. > > What is the non-DEBUG use case do you have? Is this acceptable to it? Rejecting non-Encoding Standard chardet guesses before we figure out if mailnews needs charder to be ably to guess ISO-2022-KR/CN and some Cyrillic encoding whose name escapes me now. > How about > nsCString label(aEncoding); > ToLowerCase(label); > return NS_SUCCEEDED(nsUConvPropertySearch::SearchPropertyValue( > labelsEncodings, ArrayLength(labelsEncodings), label, enc)) && > aEncoding.Equals(enc); > ? OK. I didn't do that, because "replacement" needs special casing, but then I special-cased it anyway for another reason. I'll change the patch.
No longer blocks: 863728
Comment on attachment 829217 [details] [diff] [review] Add IsEncoding Assuming the new patch will be created.
Attachment #829217 - Flags: review?(VYV03354)
It turns out that I didn't need this after all.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: