Bug 362401

Summary: KCharsets::codecForName() returns null for "ISO 2022-JP"
Product: [Frameworks and Libraries] frameworks-kdelibs4support Reporter: Mikiya Okuno <mikiya.okuno>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 5.20.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
URL: http://api.kde.org/frameworks-api/frameworks5-apidocs/kcodecs/html/classKCharsets.html
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Mikiya Okuno 2016-04-28 09:36:13 UTC
It only accepts "ISO-2022-JP", as defined in "static const char builtin_string[]" in kcharsets.cpp. IMHO, KCharsets::codecForName() should accept charset name with or without hyphens.

Doe to this, Konversation crashed for my environment, where one of IRC server has ISO 2022-JP charset :(

Reproducible: Always

Steps to Reproduce:
1. Call KCharsets::charsets()->codecForName("ISO 2022-JP");
2. Call KCharsets::charsets()->codecForName("ISO-2022-JP");
3. Compare difference

Actual Results:  
KCharsets::charsets()->codecForName("ISO 2022-JP") retunrs NULL

Expected Results:  
Shoudl return same result as KCharsets::charsets()->codecForName("ISO-2022-JP").

n/a
Comment 1 Eike Hein 2016-05-03 06:54:52 UTC
Git commit 994f45aca0061498d4e46ad601fae11cf3c0b7e4 by Eike Hein.
Committed on 03/05/2016 at 06:51.
Pushed by hein into branch 'master'.

Japanese charsets fixes.

We used to override QTextCodec::codecForLocale() by explicitly
defaulting to jis7 for jp_JP, but KCharsets/Qt5 seem to no longer
support jis7. We also used to mangle ISO-2022-JP to jis7 - which
actually is supported. So lets default to ISO-2022-JP and mangle
jis7 to ISO 2022-JP instead to keep existing configs working ...

However this showed up as a crash due to not checking for null
codecs, so let's add a check too.

M  +9    -5    src/identity.cpp
M  +10   -9    src/irc/irccharsets.cpp

http://commits.kde.org/konversation/994f45aca0061498d4e46ad601fae11cf3c0b7e4
Comment 2 Eike Hein 2016-07-21 19:12:49 UTC
Git commit a90f9d89104f4e343453c67e2d26be7b1c2e5b4a by Eike Hein.
Committed on 21/07/2016 at 19:11.
Pushed by hein into branch '1.6'.

Japanese charsets fixes.

We used to override QTextCodec::codecForLocale() by explicitly
defaulting to jis7 for jp_JP, but KCharsets/Qt5 seem to no longer
support jis7. We also used to mangle ISO-2022-JP to jis7 - which
actually is supported. So lets default to ISO-2022-JP and mangle
jis7 to ISO 2022-JP instead to keep existing configs working ...

However this showed up as a crash due to not checking for null
codecs, so let's add a check too.

M  +9    -5    src/identity.cpp
M  +10   -9    src/irc/irccharsets.cpp

http://commits.kde.org/konversation/a90f9d89104f4e343453c67e2d26be7b1c2e5b4a