Re: display undeclared iso-charset in UTF environment

Christian Ebert <[email protected]>
Newsgroups gmane.network.slrn.user
Organization Black Trash Productions <http://www.blacktrash.org/>
Message-ID <[email protected]>
Hi Alain,

* Alain Bench on Tuesday, September 12, 2006 at 15:49:07 +0200:
>  On Sunday, September 10, 2006 at 17:08:01 +0200, Christian Ebert wrote:
> 
>     [auto-sensing]
> 
>     Problem: The goal of the candidate loop is to guess the origin
> charset of the article. This is independant from reader's locale, hence
> the "-t utf-8" of my pseudo code (I could have choosen -t ucs-4, or any
> *whole* Unicode charset). Removing it broke the goal: The guessing loop
> perturbated by current locale may well miss the right candidate.
> 
>     Example: In a Latin-1 locale, an UTF-8 article containing an €uro
> will fail the UTF-8 (to L1) candidate test, and will fallback wrongly to
> CP-1252. Visual result: The 3 chars "â?¬".

And I was wondering already where those €uros had gone ...

>     Solution: Readd the "-t utf-8" in the loop. Or "-t UCS-4" if it's
> faster (probably is).

done
 
>> The calls to iconv are a bit expensive and noisy
> 
>     Noisy? With the --silent > /dev/null? What do you mean?

Screen flicker. Fixed, albeit in a dirty way: as system() always
prints something, be it only an empty line, I now use popen().

>     Expensive: Yes. But I just thought about a possible shortcut: If
> guessing loop fails, we fallback to last candidate in list, right? So
> why test -f last -t UTF-8 at all? Needless. Let's just loop all but last
> candidates, and if all fail convert -f last (implicitly -t locale) and
> display. Economy: 1 iconv call. And if the list contains 1 charset only,
> skip the guessing loop completely.

done

>> though I /should/ be doing supposedly more important stuff
> 
>     If you mean a romance, OK: Just why are you still reading this mail?
> But if you mean daywork, you'll get more €uros here, trust me. ;-)

Art is a demanding mistress. And the separation between daywork
and romance is blurred -- which is why I love it, and sometimes
hate it, and sometimes both at the same time.

c
-- 
_B A U S T E L L E N_ lesen! --->> <http://www.blacktrash.org/baustellen.html>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
guess-charset.sl.gz (application/x-gunzip, 3.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.