/* LibRCC - ISO8859-1/UTF-8 detection engine Copyright (C) 2005-2008 Suren A. Chilingaryan This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include #include #include #define bit(i) (1<0) { if ((buf[i]&0xC0)==0x80) { if (rflag) { // Western is 0x100-0x17e res++; } bytes--; } else { res--; bytes=1-bytes; rflag=0; } } else { for (j=6;j>=0;j--) if ((buf[i]&bit(j))==0) break; if ((j==0)||(j==6)) { if ((j==6)&&(bytes<0)) bytes++; else res--; continue; } bytes=6-j; if (bytes==1) { // Western Languages (C2-C3) if (buf[i]==0xC2) rflag=1; else if (buf[i]==0xC3) rflag=2; } } if ((buf[i]==0xC0)||(buf[i]==0xC1)) { if (i+1==len) break; } } if (res > 0) return (rcc_autocharset_id)0; return (rcc_autocharset_id)1; } static rcc_engine western_engine = { "Western", NULL, NULL, &AutoengineWestern, {"UTF-8","ISO8859-1", NULL} }; rcc_engine *rccGetInfo(const char *lang) { if (!lang) return NULL; return &western_engine; }