Project

General

Profile

Feature #1852

iconv doesn't handle "" encoding strings

Added by Josef Sipek over 8 years ago. Updated over 8 years ago.

Status:
New
Priority:
Normal
Category:
-
Start date:
2011-12-04
Due date:
% Done:

90%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

GNU iconv allows an empty string to be specified for an encoding. The manpage says:

The empty encoding name "" is equivalent to "char": it denotes the locale dependent character encoding.

#include <stdlib.h>
#include <stdio.h>
#include <iconv.h>

#define die(n) do { printf("BAD @ %d\n", __LINE__); return (n); } while(0)

int main () {
  iconv_t cd;
  cd = iconv_open("","UTF-8");
  if(cd == (iconv_t)(-1)) die(1);
  iconv_close(cd);
  exit(0);
}
$ truss ./a.out 
execve("a.out", 0x08047830, 0x08047838)  argc = 1
sysinfo(SI_MACHINE, "i86pc", 257)    = 6
mmap(0x00000000, 32, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFB0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFA0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEF90000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEF80000
memcntl(0xFEFB5000, 32208, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
memcntl(0x08050000, 2648, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12
getcwd("/tmp", 1017)        = 0
resolvepath("/tmp/a.out", "/tmp/a.out", 1023)  = 10
stat64("/tmp/a.out", 0x08047474)    = 0
open("/var/ld/ld.config", O_RDONLY)    Err#2 ENOENT
stat64("/lib/libc.so.1", 0x08046C24)    = 0
resolvepath("/lib/libc.so.1", "/lib/libc.so.1", 1023) = 14
sysconfig(_CONFIG_PAGESIZE)      = 4096
open("/lib/libc.so.1", O_RDONLY)    = 3
mmapobj(3, MMOBJ_INTERPRET, 0xFEFA0D68, 0x08046C90, 0x00000000) = 0
close(3)          = 0
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEE10000
memcntl(0xFEE20000, 179324, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
mmap(0x00010000, 24576, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON|MAP_ALIGN, -1, 0) = 0xFEE00000
getcontext(0x080472D4)
getrlimit(RLIMIT_STACK, 0x080472CC)    = 0
getpid()          = 102723 [102722]
lwp_private(0, 1, 0xFEE02A40)      = 0x000001C3
setustack(0xFEE02AA0)
sysi86(SI86FPSTART, 0xFEF6FC80, 0x0000133F, 0x00001F80) = 0x00000001
brk(0x08061028)          = 0
brk(0x08063028)          = 0
access("/usr/lib/iconv/geniconvtbl/binarytables/UTF-8%.bt", R_OK) Err#2 ENOENT
access("/usr/lib/iconv/UTF-8%.so", R_OK)  Err#2 ENOENT
open("/usr/lib/iconv/alias", O_RDONLY)    = 3
fstat64(3, 0x08047710)        = 0
mmap(0x00000000, 7993, PROT_READ, MAP_SHARED, 3, 0) = 0xFEDF0000
close(3)          = 0
munmap(0xFEDF0000, 7993)      = 0
access("/usr/lib/iconv/geniconvtbl/binarytables/UTF-8%.bt", R_OK) Err#2 ENOENT
access("/usr/lib/iconv/UTF-8%.so", R_OK)  Err#2 ENOENT
ioctl(1, TCGETA, 0x080468D0)      = 0
fstat64(1, 0x08046830)        = 0
BAD @ 10
write(1, " B A D   @   1 0\n", 9)    = 9
_exit(1)

History

#1

Updated by Josef Sipek over 8 years ago

I should add, I ran into this while trying to compile R. It's configure script checks to make sure that it can convert to and from "" for several different encodings.

#2

Updated by Andrew Stormont over 8 years ago

It seems our version of iconv does not support "char" either.

#3

Updated by Andrew Stormont over 8 years ago

  • Assignee set to Andrew Stormont
  • % Done changed from 0 to 90

I have a fix. Not sure if it's completely sane but it seems to work. Will send for review later today after more testing.

Also available in: Atom PDF