First public contribution.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 #define ARRAY_LENGTH(aArray) (sizeof(aArray)/sizeof((aArray)[0]))
24 LOCAL_D const SCnvConversionData::SVariableByteData::SRange iso88591VariableByteDataRanges[]=
34 LOCAL_D const SCnvConversionData::SOneDirectionData::SRange iso88591ToUnicodeDataRanges[]=
39 SCnvConversionData::SOneDirectionData::SRange::EDirect,
50 SCnvConversionData::SOneDirectionData::SRange::EDirect,
61 SCnvConversionData::SOneDirectionData::SRange::EOffset,
65 STATIC_CAST(TUint, 8236)
70 LOCAL_D const SCnvConversionData::SOneDirectionData::SRange unicodeToIso88591DataRanges[]=
75 SCnvConversionData::SOneDirectionData::SRange::EDirect,
86 SCnvConversionData::SOneDirectionData::SRange::EDirect,
97 SCnvConversionData::SOneDirectionData::SRange::EOffset,
101 STATIC_CAST(TUint, -8236)
106 GLREF_D const SCnvConversionData iso88591ConversionData=
108 SCnvConversionData::EUnspecified,
110 ARRAY_LENGTH(iso88591VariableByteDataRanges),
111 iso88591VariableByteDataRanges
114 ARRAY_LENGTH(iso88591ToUnicodeDataRanges),
115 iso88591ToUnicodeDataRanges
118 ARRAY_LENGTH(unicodeToIso88591DataRanges),
119 unicodeToIso88591DataRanges
125 GLREF_C void IsCharacterSetISO88591(TInt& aConfidenceLevel, const TDesC8& aSample)
127 TInt sampleLength = aSample.Length();
128 aConfidenceLevel = 75;
130 for (TInt i=0; i<sampleLength; ++i)
132 // ISO88591 includes ASCII as well
133 // first check if the char is in the range 0x80 - 0x9f (controls codes)
134 // If it is in that range then it's not ISO88591
135 if ((aSample[i] >= 0x80) && (aSample[i] <= 0x9f))
140 // 0xf7 is the division symbol in ISO88591.
141 // 0xd7 is the division symbol in ISO88591.If char on either side of the division
142 // symbol is a number then the confidence that it's ISO88591 increases
143 if( i>0 && ((aSample[i]==0xf7) || (aSample[i]==0xd7)) && ((i+1)<sampleLength) )
145 if ( (aSample[i-1] >= 0x30) && (aSample[i-1] <= 0x39) && // char before is a number
146 (aSample[i+1] >= 0x30) && (aSample[i+1] <= 0x39) ) // char after is a number
151 // Can also use the currency symbol to increase confidence if the char after a
152 // currency symbol is numeric
153 if((aSample[i]>=0xa2) && (aSample[i] <= 0xa5) && ((i+1)<sampleLength))
155 if ((aSample[i+1] >= 0x30) && (aSample[i+1] <= 0x39))
161 aConfidenceLevel =(aConfidenceLevel >0)? ((aConfidenceLevel > 100)? 100: aConfidenceLevel): 0;