sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #define ARRAY_LENGTH(aArray) (sizeof(aArray)/sizeof((aArray)[0])) sl@0: sl@0: LOCAL_D const SCnvConversionData::SVariableByteData::SRange iso88591VariableByteDataRanges[]= sl@0: { sl@0: { sl@0: 0x00, sl@0: 0xff, sl@0: 0, sl@0: 0 sl@0: } sl@0: }; sl@0: sl@0: LOCAL_D const SCnvConversionData::SOneDirectionData::SRange iso88591ToUnicodeDataRanges[]= sl@0: { sl@0: { sl@0: 0x00, sl@0: 0x7f, sl@0: SCnvConversionData::SOneDirectionData::SRange::EDirect, sl@0: 0, sl@0: 0, sl@0: { sl@0: 0, sl@0: 0 sl@0: } sl@0: }, sl@0: { sl@0: 0x81, sl@0: 0xff, sl@0: SCnvConversionData::SOneDirectionData::SRange::EDirect, sl@0: 0, sl@0: 0, sl@0: { sl@0: 0, sl@0: 0 sl@0: } sl@0: }, sl@0: { sl@0: 0x80, sl@0: 0x80, sl@0: SCnvConversionData::SOneDirectionData::SRange::EOffset, sl@0: 0, sl@0: 0, sl@0: { sl@0: STATIC_CAST(TUint, 8236) sl@0: } sl@0: } sl@0: }; sl@0: sl@0: LOCAL_D const SCnvConversionData::SOneDirectionData::SRange unicodeToIso88591DataRanges[]= sl@0: { sl@0: { sl@0: 0x0000, sl@0: 0x007f, sl@0: SCnvConversionData::SOneDirectionData::SRange::EDirect, sl@0: 1, sl@0: 0, sl@0: { sl@0: 0, sl@0: 0 sl@0: } sl@0: }, sl@0: { sl@0: 0x0081, sl@0: 0x00ff, sl@0: SCnvConversionData::SOneDirectionData::SRange::EDirect, sl@0: 1, sl@0: 0, sl@0: { sl@0: 0, sl@0: 0 sl@0: } sl@0: }, sl@0: { sl@0: 0x20ac, sl@0: 0x20ac, sl@0: SCnvConversionData::SOneDirectionData::SRange::EOffset, sl@0: 1, sl@0: 0, sl@0: { sl@0: STATIC_CAST(TUint, -8236) sl@0: } sl@0: } sl@0: }; sl@0: sl@0: GLREF_D const SCnvConversionData iso88591ConversionData= sl@0: { sl@0: SCnvConversionData::EUnspecified, sl@0: { sl@0: ARRAY_LENGTH(iso88591VariableByteDataRanges), sl@0: iso88591VariableByteDataRanges sl@0: }, sl@0: { sl@0: ARRAY_LENGTH(iso88591ToUnicodeDataRanges), sl@0: iso88591ToUnicodeDataRanges sl@0: }, sl@0: { sl@0: ARRAY_LENGTH(unicodeToIso88591DataRanges), sl@0: unicodeToIso88591DataRanges sl@0: }, sl@0: NULL, sl@0: NULL sl@0: }; sl@0: sl@0: GLREF_C void IsCharacterSetISO88591(TInt& aConfidenceLevel, const TDesC8& aSample) sl@0: { sl@0: TInt sampleLength = aSample.Length(); sl@0: aConfidenceLevel = 75; sl@0: sl@0: for (TInt i=0; i= 0x80) && (aSample[i] <= 0x9f)) sl@0: { sl@0: aConfidenceLevel=0; sl@0: break; sl@0: } sl@0: // 0xf7 is the division symbol in ISO88591. sl@0: // 0xd7 is the division symbol in ISO88591.If char on either side of the division sl@0: // symbol is a number then the confidence that it's ISO88591 increases sl@0: if( i>0 && ((aSample[i]==0xf7) || (aSample[i]==0xd7)) && ((i+1)= 0x30) && (aSample[i-1] <= 0x39) && // char before is a number sl@0: (aSample[i+1] >= 0x30) && (aSample[i+1] <= 0x39) ) // char after is a number sl@0: { sl@0: aConfidenceLevel+=5; sl@0: } sl@0: } sl@0: // Can also use the currency symbol to increase confidence if the char after a sl@0: // currency symbol is numeric sl@0: if((aSample[i]>=0xa2) && (aSample[i] <= 0xa5) && ((i+1)= 0x30) && (aSample[i+1] <= 0x39)) sl@0: { sl@0: aConfidenceLevel+=5; sl@0: } sl@0: } sl@0: } // for loop sl@0: aConfidenceLevel =(aConfidenceLevel >0)? ((aConfidenceLevel > 100)? 100: aConfidenceLevel): 0; sl@0: }