Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ module_iconv (RECODE_OUTER outer)
RECODE_ALIAS alias
= recode_find_alias (outer, *cursor, ALIAS_FIND_AS_CHARSET);

/* If there is a charset contradiction, call recode_declare_alias
nevertheless, as the error processing will occur there. */
if (!alias || alias->symbol->name != charset_name)
/* Only declare aliases not already known. Some iconv
implementations (notably macOS libiconv) list the same alias
under more than one charset group, e.g. WINDOWS-874 under both
CP1162 and CP874; keep the first binding rather than aborting. */
if (!alias)
if (!recode_declare_alias (outer, *cursor, charset_name))
return false;
}
Expand Down
15 changes: 14 additions & 1 deletion tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ def digest(self):
libc = None
import os
names = []
seen = set()
for line in os.popen('iconv -l'):
if libc is None:
libc = len(line.split('/')) == 3
Expand All @@ -484,7 +485,19 @@ def digest(self):
if alias in canonical:
alias = canonical[alias]
aliases.append(alias)
self.data.append((aliases[0], aliases[1:]))
# Prefer the first charset group for each alias name. Some
# iconv implementations (macOS libiconv) repeat names across
# groups — e.g. WINDOWS-874 under both CP1162 and CP874 —
# which would otherwise make module_iconv abort.
filtered = []
for alias in aliases:
key = alias.upper()
if key in seen:
continue
seen.add(key)
filtered.append(alias)
if filtered:
self.data.append((filtered[0], filtered[1:]))

def complete(self, french):
def write_charset(format, charset):
Expand Down