From: Ben Pfaff Date: Wed, 27 Apr 2011 04:36:24 +0000 (-0700) Subject: encoding-guesser: Don't guess UTF-8 for ASCII if it is the fallback. X-Git-Tag: v0.7.8~26 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=888d895ec5bfcc439c8174184c388f3be3f117a0 encoding-guesser: Don't guess UTF-8 for ASCII if it is the fallback. When the text presented to the encoding guesser is all ASCII, normally the encoding guesser will report ASCII as its guess. But if the fallback encoding is UTF-8, then it reports UTF-8 instead. Unfortunately, this makes the encoding guesser a bit harder to test, because guesses depend on the system's locale. It's easier to test if all-ASCII always yields ASCII as the guess, so this changes the encoding guesser to do that. This fixes a test failure on Mac OS X. Thanks to Jeremy Lavergne for reporting the problem. --- diff --git a/src/libpspp/encoding-guesser.c b/src/libpspp/encoding-guesser.c index 9042e93a..298861e0 100644 --- a/src/libpspp/encoding-guesser.c +++ b/src/libpspp/encoding-guesser.c @@ -250,10 +250,6 @@ encoding_guess_head_encoding (const char *encoding, || !encoding_guess_tail_is_utf8 (data, n)) return fallback_encoding; - if (!c_strcasecmp (fallback_encoding, "UTF-8") - || !c_strcasecmp (fallback_encoding, "UTF8")) - return "UTF-8"; - return "ASCII"; }