We're updating the issue view to help you get more done. 

ucbuf_autodetect() doesn't autodetect on T_FileStream_stdin() correctly

Description

gabier% ./genrb -v ../../../../icu/source/data/locales/zh_TW.txt
processing file "../../../../icu/source/data/locales/zh_TW.txt"
autodetected encoding UTF-8
gabier% cat ../../../../icu/source/data/locales/zh_TW.txt | ./genrb -v -
processing file "-"
gabier% ls -l *TW.res
rw-rr- 1 yves yves 157588 May 1 12:28 zh_TW.res
rw-rr- 1 yves yves 160468 May 1 12:28 ??? zh_TW.res
gabier%

As one can see, when genrb used T_FileStream_stdin() instead of opening a file,
it
was not able to autodetect the UTF-8 encoding, and concatenated the UTF-8 BOM
with
the name of the locale, even though there are comments between the two (that
should
warrant a different bug report I am sure)!

I believe the problem is not with genrb itself but maybe with the T_FileStream
and
autodected implementations, since genrb simply does:

if(in == 0) {
*status = U_FILE_ACCESS_ERROR;
fprintf(stderr, "couldn't open file %s\n", openFileName == NULL ?
filename : openFileName);
goto finish;
} else {
/* auto detect popular encodings */
if (*cp=='\0' && ucbuf_autodetect(in, &cp) && verbose) {
printf("autodetected encoding %s\n", cp);
}
}

i.e. has no special handling for stdin versus a regular file.

YA

Environment

Status

Assignee

TracBot

Reporter

TracBot

Labels

tracCreated

May 01, 2002, 10:34 PM

tracOwner

ram

tracProject

ICU4C,ICU4J and ICU4JNI

tracReporter

yves@3d6bff282d01d21e

tracResolution

fixed

tracReviewer

markus

tracStatus

closed

Components

Fix versions

Priority

major