1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/charconvfw/charconvplugins/test/rtest/tsrc/main/t_autodetect.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,752 @@
1.4 +/*
1.5 +* Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <e32base.h>
1.24 +#include <f32file.h>
1.25 +#include <charconv.h>
1.26 +#include "t_autodetect.h"
1.27 +
1.28 +_LIT8(KUnicode,"ÿþHi there");
1.29 +_LIT8(KUnicode2, "\xff\xfe\x48\x00\x69\x00\x20\x00\x74\x00\x68\x00\x65\x00\x72\x00\x65\x00");
1.30 +_LIT8(KUnicode3, "\xfe\xff\x48\x00\x69\x00\x20\x00\x74\x00\x68\x00\x65\x00\x72\x00\x65\x00");
1.31 +_LIT8(KSMS7InvalidEmail, "\x21\x00\x70\x2e\x63 \x21\x00\x70\x2e\x63 \x21\x00\x70\x2e\x63\x7e\x7e");
1.32 +_LIT8(KSMS7ValidEmail, "\x42\x00\x70\x2e\x63 \x42\x00\x70\x2e\x63 \x42\x00\x70\x2e\x63\x7e\x7e");
1.33 +_LIT8(KSJISPhrase, "\x81@\x81y\x83o\x83\x93\x83R\x83N\x82Q\x82T\x93\xfa\x81\x81\x89\xaa\x93""c\x8e\xa0\x8ds\x81z\x83\x84\x83\x93\x83S\x83\x93\x82\xa9\x82\xe7\x82\xcc\x8f\xee\x95\xf1\x82\xc9\x82\xe6\x82\xe9\x82\xc6\x81""A\x83~\x83\x83\x83\x93\x83}\x81[\x82\xcc\x96\xaf\x8e\xe5\x89\xbb\x89^\x93\xae\x8ew\x93\xb1\x8e\xd2\x83""A\x83""E\x83\x93\x81""E\x83T\x83\x93\x81""E\x83X\x81[\x81""E\x83`\x81[\x82\xb3\x82\xf1\x82\xe7\x8d\x91\x96\xaf\x96\xaf\x8e\xe5\x98""A\x96\xbf\x81i\x82m\x82k\x82""c\x81j\x82\xcc\x83\x81\x83\x93\x83o\x81[\x82\xaa\x93\xf1\x8f\\x8el\x93\xfa\x81""A\x8e\xd4\x82\xc5\x83\x84\x83\x93\x83S\x83\x93\x8dx\x8aO\x82\xc9\x8fo\x82\xbd\x82\xc6\x82\xb1\x82\xeb\x81""A\x8cR\x90\xad\x93\x96\x8b\xc7\x82\xc9\x90\xa7\x8e~\x82\xb3\x82\xea\x82\xbd\x82\xbd\x82\xdf\x81""A\x93\xb9\x98H\x82\xed\x82\xab\x82\xc9\x88\xda\x82\xb3\x82\xea\x82\xbd\x8e\xd4\x93\xf1\x91\xe4\x82\xcc\x92\x86\x82\xc5\x82\xeb\x82\xa4\x8f\xe9\x82\xf0\x8en\x82\xdf\x82\xbd\x81""B\x83X\x81[\x81""E\x83`\x81[\x82\xb3\x82\xf1\x82\xaa\x81""A\x93\x96\x8b\xc7\x82\xcc\x8ds\x93\xae\x90\xa7\x8c\xc0\x82\xf0\x94j\x82\xc1\x82\xc4\x8dx\x8aO\x82\xc9\x8fo\x82\xbd\x82\xcc\x82\xcd\x8b\xe3\x94\xaa\x94N\x94\xaa\x8c\x8e\x88\xc8\x97\x88\x81""A\x93\xf1\x94N\x82\xd4\x82\xe8\x81""B\x96\xaf\x8e\xe5\x89\xbb\x89^\x93\xae\x82\xd6\x82\xcc\x8d\x91\x8d\xdb\x93I\x82\xc8\x8ex\x8e\x9d\x8fW\x82\xdf\x82\xf0\x91_\x82\xc1\x82\xc4\x92\xb7\x8a\xfa\x82\xeb\x82\xa4\x8f\xe9\x82\xf0\x8ds\x82\xa4\x89\xc2\x94\\x90\xab\x82\xe0\x82\xa0\x82\xe8\x81""A\x8cR\x90\xad\x91\xa4\x82\xcd\x91\xce\x89\x9e\x82\xc9\x8b\xea\x97\xb6\x82\xb5\x82\xc4\x82\xa2\x82\xe9\x81""B<p>");
1.34 +_LIT8(KBig5, "\xa1@\xa1@\xa5\xbb\xb3\xf8\xb0T\xa1]\xb0O\xaa\xcc\xb1\xe4\xd9y\xa1^\xac\xb0\xb3""e\xb9\xfd\xb8\xa8\xb9\xea\xa4\xa4\xa5\xa1\xa6\xe8\xb3\xa1\xa4j\xb6}\xb5o\xbe\xd4\xb2\xa4\xa9M\xa7\xf5\xb4P\xb2M\xb0\xc6\xc1`\xb2z\xc3\xf6\xa4_\xb1\xd0\xa8|\xb9\xef\xa4""f\xa4\xe4\xb4\xa9\xab\xfc\xa5\xdc\xba\xeb\xaf\xab\xa1""A\xa5\xbb\xa5\xab\xb1N\xb2\xd5\xc2\xb4\xb1\xd0\xaev\xb9\xce\xadu\xa4\xba\xbbX\xa5j\xb6}\xaei\xb9\xef\xa4""f\xa4\xe4\xb4\xa9\xa1""A\xad\xba\xa7\xe5""115\xa6W\xb1\xd0\xaev\xb1N\xa6""b\xb7s\xbe\xc7\xb4\xc1\xb6}\xbe\xc7\xa4\xa7\xbb\xda\xb1\xd2\xb5{\xadu\xa4\xba\xbbX\xa5j\xa1""C\xacQ\xa4\xd1\xa4W\xa4\xc8\xa1""A\xa5\xab\xa9""e\xae\xd1\xb0O");
1.35 +_LIT8(KEUP, "\xa1\xcb\xa1\xa3\xa4\xb3\xa4\xec\xa4\xcf\xa1\xa4\xb9\xe2\xc9\xe9\xb2\xd9\xa4\xce\xa5\xd9\xa5\xf3\xa5\xc1\xa5\xde\xa1\xbc\xa5\xaf\xa4\xe4\xa5\xa2\xa5\xd7\xa5\xea\xa5\xb1\xa1\xbc\xa5\xb7\xa5\xe7\xa5\xf3\xa4\xf2\xbc\xc2\xb9\xd4\xa4\xb9\xa4\xeb\xa4\xc8\xa1\xa4\xbd\xe8\xcd\xfd\xa4\xac\xb4\xb0\xce\xbb\xa4\xb9\xa4\xeb\xc1\xb0\xa4\xcb\xa5\xd5\xa5\xea\xa1\xbc\xa5\xba\xa4\xb9\xa4\xeb\xc9\xd4\xb6\xf1\xb9\xe7\xa4\xac\xb3\xce\xc7\xa7\xa4\xb5\xa4\xec\xa4\xbf\xa4\xbf\xa4\xe1\xa1\xa3\xa4\xb7\xa4\xab\xa4\xb7\xcc\xe4\xc2\xea\xa4\xcf\xa1\xa4\xa4\xbd\xa4\xce\xb8\xb6\xb0\xf8\xa4\xac\xa1\xd6\xa5\xb7\xa5\xea\xa5\xb3\xa5\xf3\xa4\xce\xa5\xde\xa1\xbc\xa5\xb8\xa5\xf3\xc9\xd4\xc2\xad\xa1\xd7\xa4\xc0\xa4\xc3\xa4\xbf\xc5\xc0\xa4\xc0\xa1\xa3");
1.36 +_LIT8(KEUC2, "Enlightenment\xa4\xce\xa5\xc6\xa1\xbc\xa5\xde\xa4\xc8\xa4\xcf\xa1\xa2\xa5\xa6\xa5\xa3\xa5\xf3\xa5\xc9\xa5\xa6\xa5\xde\xa5\xcd\xa1\xbc\xa5\xb8\xa5\xe3\xa4\xce\xb3\xb0\xb4\xd1\xc9\xf4\xca\xac\xa4\xce\xcd\xd7\xc1\xc7\xa4\xf2\xa4\xd2\xa4\xc8\xa4\xde\xa4\xc8\xa4\xe1\xa4\xcb\xa4\xb7\xa4\xc6\xc0\xda\xa4\xea\xc2\xd8\xa4\xa8\xa4\xe9\xa4\xec\xa4\xeb\xa4\xe8\xa4\xa6\xa4\xcb\xa4\xb7\xa4\xbf\xa4\xe2\xa4\xce\xa1\xa2\xa4\xc8\xb9\xcd\xa4\xa8\xa4\xeb\xa4\xb3\xa4\xc8\xa4\xac\xa4\xc7\xa4\xad\xa4\xde\xa4\xb9\xa1\xa3\xa4\xc4\xa4\xde\xa4\xea\xa1\xa2""1\xa4\xc4\xa4\xce\xa5\xa6\xa5\xa3\xa5\xf3\xa5\xc9\xa5\xa6\xa5\xde\xa5\xcd\xa1\xbc\xa5\xb8\xa5\xe3\xa4\xca\xa4\xce\xa4\xcb\xa1\xa2Windows\xc9\xf7\xa4\xcb\xa4\xe2\xa1\xa2Mac\xc9\xf7\xa4\xcb\xa4\xe2\xa1\xa2\xa4\xb5\xa4\xde\xa4\xb6\xa4\xde\xa4\xcb\xa5\xab\xa5\xb9\xa5\xbf\xa5\xde\xa5\xa4\xa5\xba\xa4\xb9\xa4\xeb\xa4\xb3\xa4\xc8\xa4\xac\xa4\xc7\xa4\xad\xa4\xde\xa4\xb9\xa1\xa3");
1.37 +_LIT8(KSJIS, "\x82\xb1\x82\xcc\x83z\x81[\x83\x80\x83y\x81[\x83W\x82\xcd\x81""A\x82\xa9\x82\xed\x82\xa2\x82\xa2\x83L\x83\x83\x83\x89\x83N\x83^\x81[\x81g\x83s\x83\x93\x83O\x81[\x81h\x82\xf0\x82\xbd\x82\xad\x82\xb3\x82\xf1\x82\xcc\x90l\x82\xbd\x82\xbf\x82\xc9\x8f\xd0\x89\xee\x82\xb5\x81""A\x82\xdc\x82\xbd\x81""A\x8c\xf0\x97\xac\x82\xf0\x8e\x9d\x82\xc1\x82\xc4\x82\xa2\x82\xbd\x82\xbe\x82\xab\x82\xbd\x82\xa2\x82\xc6\x8ev\x82\xc1\x82\xc4\x8d\xec\x90\xac\x82\xb3\x82\xea\x82\xbd\x83y\x81[\x83W\x82\xc5\x82\xb7\x81""B<B>\x82\xb1\x82\xcc\x83z\x81[\x83\x80\x83y\x81[\x83W\x82\xcd\x8a""F\x82\xb3\x82\xf1\x82\xcc\x81g\x83N\x83`\x83R\x83~\x81h\x82\xc5\x90\xac\x82\xe8\x97\xa7\x82\xc1\x82\xc4\x82\xa2\x82\xdc\x82\xb7\x81""B</B>\x82\xba\x82\xd0\x8f\xee\x95\xf1\x82\xf0\x82\xa8\x8a\xf1\x82\xb9\x89\xba\x82\xb3\x82\xa2\x81I");
1.38 +_LIT8(SJISNET, "20\x94NTRUSTe\x93\xfa\x96{\x82\xcd\x81""A\x8f\xee\x95\xf1\x82\xcc\x8aJ\x8e\xa6\x82\xc6\x8d\x90\x92m\x8b`\x96\xb1\x82\xc9\x8a\xd6\x82\xb7\x82\xe9\x8c\xb4\x91\xa5\x82\xf0\x8dL\x82\xdf\x82\xe9\x82\xb1\x82\xc6\x82\xc9\x82\xe6\x82\xe8\x81""A\x83""C\x83\x93\x83^\x81[\x83l\x83""b\x83g\x8f\xe3\x82\xc9\x82\xa8\x82\xaf\x82\xe9\x83\x86\x81[\x83U\x81[\x82\xc6\x82\xcc\x8f\xee\x95\xf1\x8aJ\x8e\xa6\x82\xc9\x8a\xd6\x82\xb7\x82\xe9\x90M\x97\x8a\x8a\xd6\x8cW\x82\xf0\x91\xc5\x82\xbf\x97\xa7\x82\xc4\x82\xe9\x82\xb1\x82\xc6\x82\xf0\x8eg\x96\xbd\x82\xc6\x82\xb7\x82\xe9\x81""A\x93\xc6\x97\xa7\x82\xcc\x94\xf1\x89""c\x97\x98\x91g\x90""D\x82\xc5\x82\xb7\x81""B\x82\xb1\x82\xcc\x83""E\x83""F\x83u\x83T\x83""C\x83g\x82\xcd\x8bM\x93""a\x82\xcc\x83v\x83\x89\x83""C\x83o\x83V\x81[\x82\xc9\x91\xce\x82\xb7\x82\xe9\x82\xbb\x82\xcc\x8c\xf6\x96\xf1\x82\xf0\x8e\xc0\x8f\xd8\x82\xb7\x82\xe9\x88\xd3\x96\xa1\x82\xc5\x81""A\x82\xb1\x82\xb1\x82\xc9\x8f\xee\x95\xf1\x82\xcc\x8e\xe6\x82\xe8\x88\xb5\x82\xa2\x8a\xee\x8f\x80\x82\xf0\x8aJ\x8e\xa6\x82\xb5\x82\xbd\x82\xe0\x82\xcc\x82\xc5\x81""A\x82\xb1\x82\xcc\x83v\x83\x89\x83""C\x83o\x83V\x81[\x8e\xe6\x82\xe8\x88\xb5\x82\xa2\x8a\xee\x8f\x80\x82\xc9\x82\xc2\x82\xa2\x82\xc4\x82\xcd\x81""ATRUSTe\x82\xc9\x82\xe6\x82\xe8\x81""A\x82\xbb\x82\xcc\x8f\x87\x8e\xe7\x82\xc9\x8a\xd6\x82\xb7\x82\xe9\x8c\x9f\x93\xa2\x82\xc6\x8a\xc4\x8d\xb8\x82\xc6\x82\xf0\x8e\xf3\x82\xaf\x82\xbd\x82\xe0\x82\xcc\x82\xc5\x82\xb7\x81""B");
1.39 +_LIT8(BIG5A, "\xb0\xea\xae""a\xbcs\xbc\xbd\xb9q\xb5\xf8\xbd\xe8\xb6q\xba\xca\xb7\xfe\xc0\xcb\xc5\xe7\xb4\xfa\xb8\xd5\xa4\xa4\xa4\xdf</a> - \xb9\xef\xad\xb5\xb5\xf8\xc0W\xb2\xa3\xab~\xaa\xba\xb1`\xb7\xc5\xb9q\xa9\xca\xaf\xe0\xa1""B\xa6w\xa5\xfe\xa1""B\xb9q\xba\xcf\xad\xdd\xae""e\xa7@\xc0\xf4\xb9\xd2\xb4\xfa\xb8\xd5\xa9M\xba\xca\xb7\xfe\xa9\xe2\xac""d");
1.40 +_LIT8(BIG5C, "\xac\xfc \xb0\xea \xb0\xc8 \xb0| \xa8\xc8 \xa4\xd3 \xb0\xc6 \xa7U \xad\xeb \xc1\xc2 \xb2Q \xc4R \xa4\xb5 \xa4\xe9 \xa6""b \xa6\xb9 \xb6\xa1 \xa4@ \xa6\xb8 \xbcy \xaf\xac \xa4\xa4 \xa6@ \xab\xd8 \xac""F \xa4\xad \xa4Q \xa9P \xa6~ \xaa\xba \xa4j \xab\xac \xac\xe3 \xb0Q \xb7| \xa4\xa4 \xaa\xed \xa5\xdc \xa1""A \xa4\xa4 \xa6@ \xc0\xb3 \xb8\xd3 \xb9\xef \xa5x \xc6W \xb1\xc4");
1.41 +_LIT8(GB2312B, "\xd0\xc2\xce\xc5, \xd0\xa1\xcb\xb5\xa3\xac\xd4\xd3\xd6\xbe\xa3\xac\xb6\xc1\xd5\xdf\xa3\xac\xc2\xdb\xcc\xb3\xa3\xac\xce\xc4\xd5\xaa\xa3\xac\xb1\xa8\xd6\xbd\xa3\xac\xd0\xa6\xbb\xb0\xa3\xac\xcc\xe5\xd3\xfd\xa3\xac\xc7\xe9\xb8\xd0\xa3\xac\xc1\xf4\xd1\xa7\xa3\xac\xbf\xe1\xd5\xbe\xa3\xac");
1.42 +_LIT8(GB2312C, "\xa1\xa1\xa1\xf1\xcd\xf5\xbb\xdb\xa3\xa8\xb1\xbe\xb1\xa8\xcc\xd8\xd4\xbc\xa3\xa9\xb1\xb1\xbe\xa9\xb1\xa8\xb5\xc0<p>\xa1\xa1\xa1\xa1\xc0\xfa\xbd\xec\xb0\xc2\xd4\xcb\xbb\xe1\xca\xd7");
1.43 +_LIT8(GB2312Corrupt, "\xa1\xa1\xa1\xf1\xcd\xf5\xbb\xdb\xa3""fff\xb1\xbe\xb1\xa8\xcc\xd8\xd4\xbc\xa3\xa9""ff\xb1\xb1\xbe\xa9\xb1\xa8\xb5\xc0<pddd>\xa1\xa1\xa1\xa1\xc0\xfa\xbd\xec\xb0\xc2\xd4\xcb\xbb\xe1\xca\xd7");//FAILED
1.44 +_LIT8(BIG5Corrupt, "\xac\xfc \xb0\xea \xb0\xc8 \xb0| \xa8\xc8 \xa4\xd3 \xb0\xc6 \xa7U ddd\xad\xeb \xc1\xc2 \xb2Q \xc4R \xa4""ddd\xb5 \xa4\xe9 \xa6""b \xa6\xb9 \xb6\xa1 \xa4@ \xa6\xb8 \xbcy \xaf\xac \xa4\xa4 \xa6@ \xab\xd8 \xac""F \xa4\xad \xa4Q \xa9P \xa6~ \xaa\xba \xa4j \xab\xac \xac\xe3 \xb0Q \xb7| \xa4\xa4 \xaa\xed \xa5\xdc \xa1""A \xa4\xa4 \xa6@ddd \xc0\xb3 \xb8\xd3 \xb9\xef \xa5x \xc6W \xb1\xc4");
1.45 +_LIT8(BIG5Ahalf, "this is to test the data with ASCII mixured \xea\xae""a\xbcs\xbc\xbd\xb9q\xb5\xf8\xbd\xe8\xb6q\xba\xca\xb7\xfe\xc0\xcb\xc5\xe7\xb4\xfa\xb8\xd5\xa4\xa4\xa4\xdf</a> - \xb9\xef\xad\xb5\xb5\xf8\xc0W\xb2\xa3\xab~\xaa\xba\xb1`\xb7\xc5\xb9q\xa9\xca\xaf\xe0\xa1""B\xa6w\xa5\xfe\xa1""B\xb9q\xba\xcf\xad\xdd\xae""e\xa7@\xc0\xf4\xb9\xd2\xb4\xfa\xb8\xd5\xa9M\xba\xca\xb7\xfe\xa9\xe2\xac""d");
1.46 +_LIT8(KASCII, "SO what result do I get for a text that is pure Ascii and nothing else. Not something stupid I hope!");
1.47 +_LIT8(KUTF8, "\xe4\xbc\x80\xe6\xac\x80\xe2\x80\x80\xe5\x8c\x80\xe6\xbc\x80\xe2\x80\x80\xe4\xa0\x80\xe6\x94\x80\xe7\x88\x80\xe6\x94\x80\xe2\x80\x80\xe6\xa4\x80\xe7\x8c\x80\xe2\x80\x80\xe6\x84\x80\xe2\x80\x80\xe7\x90\x80\xe6\x94\x80\xe7\xa0\x80\xe7\x90\x80\xe2\x80\x80\xe7\x90\x80\xe6\xa0\x80\xe6\x84\x80\xe7\x90\x80\xe2\x80\x80\xe7\x9c\x80\xe6\xa4\x80\xe6\xb0\x80\xe6\xb0\x80\xe2\x80\x80\xe6\x88\x80\xe6\x94\x80\xe2\x80\x80\xe6\x8c\x80\xe6\xbc\x80\xe6\xb8\x80\xe7\x98\x80\xe6\x94\x80\xe7\x88\x80\xe7\x90\x80\xe6\x94\x80\xe6\x90\x80\xe2\x80\x80\xe6\xa4\x80\xe6\xb8\x80\xe7\x90\x80\xe6\xbc\x80\xe2\x80\x80\xe6\x84\x80\xe2\x80\x80\xe5\x94\x80\xe5\x90\x80\xe4\x98\x80\xe2\xb4\x80\xe3\x9c\x80\xe2\x80\x80\xe7\xb8\x80\xe2\x80\x80\xe5\x90\x80\xe6\x94\x80\xe7\xa0\x80\xe7\x90\x80");
1.48 +_LIT8(KDodgyShiftJIS,"¡“ú‚Í’a¶“ú‚¾‚悤‚ꂵ‚¢‚È‚Ÿ`™™");
1.49 +_LIT8(KDodgyShiftJIS2,"20000222T100000Z;;;\x92\xa9\x82\xbe\x82\xe6\x8b\x4e\x82\xab\x82\xeb\x82\xa7\x81\x60\x81\x60\x81\x49\x81\x49\x81\x49");
1.50 +_LIT8(KDodgyShiftJIS3,"\x83\x5c\x83\x5c\x83\x5c\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8\x83\x5c\x83\x5c\x83\x5c\x82\xa9\x82\xab\x82\xad\x82\xaf\x82\xb1\x82\x5c");
1.51 +_LIT8(KISO,"\x6d\x6f\x72\x6f\x0d\x0a\x6d\x69\x74\xe4\x20\x6b\x75\x75\x6c\x75\x75\x3f");
1.52 +_LIT8(KSomeISO, "\x48\x65\x6a\x21\x20\x0d\x0a\x0d\x0a\x68\xe4\x72\x20\x6b\x6f\x6d\x6d\x65\x72\x20\x65\x74\x74\x20\x6d\x61\x69\x6c\x20\x6d\x65\x64\x20\x6d\x61\x73\x73\x61\x20\x74\x65\x78\x74\x20\x6f\x63\x68\x20\x65\x74\x74\x20\x61\x74\x74\x61\x63\x68\x6d\x65\x6e\x74\x2e\x20\x44\x65\x74\x74\x61\x20\x6c\x69\x6c\x6c\x61\x20\x6d\x61\x69\x6c");
1.53 +_LIT8(KUnicodeFail,"\x0d");
1.54 +_LIT8(KISODEF,"\xd7\x6d\x30\xf7"); // Test for defect raised in 6.1 (EXT-5HLEKN)
1.55 +_LIT8(KShortUnicode1, "\xff\xfe\x29\x00\x3d\x00");
1.56 +_LIT8(KShortUnicode2, "\xff\xfe\x41\x00\x61\x00");
1.57 +
1.58 +/**
1.59 +* Work around for DEF063276.
1.60 +* These literals are now loaded from a z:\test\data\KLittleEndian.dat and
1.61 +* z:\test\data\KBigEndian.dat respectivly.
1.62 +* Bullseye Coverage corrupts these literals to avoid this they are stored in files as to not be touched by Bullseye Coverage.
1.63 +*/
1.64 +
1.65 +// Test for defect INC037743 - Charconv recognises Little Endian as Big Endian
1.66 +/*_LIT8(KLittleEndian,
1.67 + "\x43\x00\x68\x00\x61\x00\x74\x00\x20\x00\x68\x00\x69\x00\x73\x00"
1.68 + "\x74\x00\x6F\x00\x72\x00\x79\x00\x20\x00\x32\x00\x0A\x00\x43\x00"
1.69 + "\x68\x00\x61\x00\x74\x00\x20\x00\x72\x00\x6F\x00\x6F\x00\x6D\x00"
1.70 + "\x20\x00\x27\x00\x77\x00\x76\x00\x3A\x00\x6A\x00\x75\x00\x68\x00"
1.71 + "\x61\x00\x75\x00\x74\x00\x69\x00\x6F\x00\x2F\x00\x32\x00\x30\x00"
1.72 + "\x70\x00\x6D\x00\x74\x00\x40\x00\x6E\x00\x6F\x00\x6B\x00\x69\x00"
1.73 + "\x61\x00\x2E\x00\x63\x00\x6F\x00\x6D\x00\x27\x00\x0A\x00\x53\x00"
1.74 + "\x74\x00\x61\x00\x72\x00\x74\x00\x3A\x00\x20\x00\x30\x00\x31\x00"
1.75 + "\x2F\x00\x30\x00\x39\x00\x2F\x00\x32\x00\x30\x00\x30\x00\x33\x00"
1.76 + "\x20\x00\x32\x00\x32\x00\x3A\x00\x34\x00\x33\x00\x3A\x00\x32\x00"
1.77 + "\x38\x00\x0A\x00\x49\x00\x76\x00\x61\x00\x6E\x00\x20\x00\x57\x00"
1.78 + "\x65\x00\x6C\x00\x63\x00\x6F\x00\x6D\x00\x65\x00\x20\x00\x74\x00"
1.79 + "\x6F\x00\x20\x00\x63\x00\x68\x00\x61\x00\x74\x00\x20\x00\x72\x00"
1.80 + "\x6F\x00\x6F\x00\x6D\x00\x21\x00\x20\x00\x54\x00\x6F\x00\x70\x00"
1.81 + "\x69\x00\x63\x00\x20\x00\x69\x00\x73\x00\x20\x00\x59\x00\x6C\x00"
1.82 + "\x65\x00\x69\x00\x73\x00\x74\x00\xE4\x00\x20\x00\x76\x00\x65\x00"
1.83 + "\x6C\x00\x6C\x00\x6F\x00\x6E\x00\x74\x00\x61\x00\x61\x00\x2E\x00"
1.84 + "\x0A\x00\x4D\x00\x69\x00\x6B\x00\x61\x00\x54\x00\x20\x00\x6A\x00"
1.85 + "\x6F\x00\x69\x00\x6E\x00\x65\x00\x64\x00\x0A\x00");
1.86 +
1.87 +_LIT8(KBigEndian,
1.88 + "\x00\x43\x00\x68\x00\x61\x00\x74\x00\x20\x00\x68\x00\x69\x00\x73"
1.89 + "\x00\x74\x00\x6F\x00\x72\x00\x79\x00\x20\x00\x32\x00\x0A\x00\x43"
1.90 + "\x00\x68\x00\x61\x00\x74\x00\x20\x00\x72\x00\x6F\x00\x6F\x00\x6D"
1.91 + "\x00\x20\x00\x27\x00\x77\x00\x76\x00\x3A\x00\x6A\x00\x75\x00\x68"
1.92 + "\x00\x61\x00\x75\x00\x74\x00\x69\x00\x6F\x00\x2F\x00\x32\x00\x30"
1.93 + "\x00\x70\x00\x6D\x00\x74\x00\x40\x00\x6E\x00\x6F\x00\x6B\x00\x69"
1.94 + "\x00\x61\x00\x2E\x00\x63\x00\x6F\x00\x6D\x00\x27\x00\x0A\x00\x53"
1.95 + "\x00\x74\x00\x61\x00\x72\x00\x74\x00\x3A\x00\x20\x00\x30\x00\x31"
1.96 + "\x00\x2F\x00\x30\x00\x39\x00\x2F\x00\x32\x00\x30\x00\x30\x00\x33"
1.97 + "\x00\x20\x00\x32\x00\x32\x00\x3A\x00\x34\x00\x33\x00\x3A\x00\x32"
1.98 + "\x00\x38\x00\x0A\x00\x49\x00\x76\x00\x61\x00\x6E\x00\x20\x00\x57"
1.99 + "\x00\x65\x00\x6C\x00\x63\x00\x6F\x00\x6D\x00\x65\x00\x20\x00\x74"
1.100 + "\x00\x6F\x00\x20\x00\x63\x00\x68\x00\x61\x00\x74\x00\x20\x00\x72"
1.101 + "\x00\x6F\x00\x6F\x00\x6D\x00\x21\x00\x20\x00\x54\x00\x6F\x00\x70"
1.102 + "\x00\x69\x00\x63\x00\x20\x00\x69\x00\x73\x00\x20\x00\x59\x00\x6C"
1.103 + "\x00\x65\x00\x69\x00\x73\x00\x74\x00\xE4\x00\x20\x00\x76\x00\x65"
1.104 + "\x00\x6C\x00\x6C\x00\x6F\x00\x6E\x00\x74\x00\x61\x00\x61\x00\x2E"
1.105 + "\x00\x0A\x00\x4D\x00\x69\x00\x6B\x00\x61\x00\x54\x00\x20\x00\x6A"
1.106 + "\x00\x6F\x00\x69\x00\x6E\x00\x65\x00\x64\x00\x0A\x00");*/
1.107 +
1.108 +// Swedish test file for INC037705, This is "test2.txt" from the defect
1.109 +_LIT8(KSwedish,
1.110 + "\x55\x74\x61\x6E\x73\x6B\x72\x69\x66\x74\x65\x6E\x3A\x0D\x0A\x53"
1.111 + "\x65\x72\x65\x6E\x69\x73\x73\x69\x6D\x6F\x20\x65\x74\x20\x43\x6C"
1.112 + "\x61\x72\x69\x73\x73\x69\x6D\x6F\x20\x44\x6F\x6D\x69\x6E\x6F\x0D"
1.113 + "\x0A\x44\x6F\x6D\x69\x6E\x6F\x20\x47\x75\x73\x74\x61\x66\x66\x6F"
1.114 + "\x20\x53\x75\x65\x63\x6F\x72\x75\x6D\x0D\x0A\x65\x74\x20\x47\x6f"
1.115 + "\x74\x68\x6F\x72\x75\x6D\x20\x52\x65\x67\x69\x20\x44\x6F\x6D\x69"
1.116 + "\x6E\x6F\x20\x53\x75\x6F\x0D\x0A\x43\x6C\x65\x6D\x65\x6E\x74\x69"
1.117 + "\x70\x70\x69\x6D\x6F\x0D\x0A\x0D\x0A\x4E\xE5\x64\x20\x6F\x63\x68"
1.118 + );
1.119 +
1.120 +// Finnish test file for INC037705, This is "test3.txt" from the defect
1.121 +_LIT8(KFinnish,
1.122 + "\x59\x68\x64\x65\x73\x74\x6F\x69\x73\x74\x61\x20\x72\x75\x6E\x6F"
1.123 + "\x0D\x0A\x0D\x0A\x56\x69\x6B\x61\x20\x6F\x6E\x20\x41\x68\x74\x69"
1.124 + "\x61\x20\x73\x61\x6E\x6F\x61\x2C\x20\x76\x65\x69\x74\x69\x6B\x6B"
1.125 + "\xE4\x74\xE4\x20\x76\x69\x65\x72\x65\x74\x65\x6C\x6C\xE4\x2E\x20"
1.126 + "\x0D\x0A\x0D\x0A\x41\x68\x74\x69\x20\x70\x6F\x69\x6B\x61\x20\x53"
1.127 + "\x61\x61\x72\x65\x6C\x61\x69\x6E\x65\x6E\x2C\x20\x74\x75\x6F\x20"
1.128 + "\x6F\x6E\x20\x6C\x69\x65\x74\x6F\x20\x4C\x65\x6D\x6D\x69\x6E\x20"
1.129 + "\x70\x6F\x69\x6B\x61\x2C\x20\x0D\x0A\x6B\x61\x73\x76\x6F\x69\x20"
1.130 + );
1.131 +
1.132 +// This is the last two lines from GotchaLog.txt
1.133 +// from INC043016 - AV21 via BTH received TXT file could not be opened
1.134 +// Which is enough to reproduce the defect
1.135 +_LIT8(KGotcha,
1.136 + "\x0A\x0D\x0A\x4D\x65\x6D\x6F\x72\x79\x20\x74\x65\x73\x74\x20\x2D"
1.137 + "\x6F\x64\x75\x6C\x65\x20\x65\x6E\x64\x0D\x0A\x2B\x2B\x2B\x2B\x2B"
1.138 + );
1.139 +
1.140 +///////////////////////////////////////////////////////////////////////////////////////
1.141 +
1.142 +//UTF8 return values.
1.143 +const TInt KUtf8NoBomMaxSuccessConfidenceLevel = 100;
1.144 +const TInt KUtf8NoBomMinSuccessConfidenceLevel = 75;
1.145 +const TInt KUtf8BomConfidenceLevel = 95;
1.146 +const TInt KUtf8NoStringConfidenceLevel = 89;
1.147 +const TInt KUtf8ConfidenceFailure = 0;
1.148 +
1.149 +#define test(cond) \
1.150 + { \
1.151 + TBool __bb = (cond); \
1.152 + TEST(__bb); \
1.153 + if (!__bb) \
1.154 + { \
1.155 + ERR_PRINTF1(_L("ERROR: Test Failed")); \
1.156 + User::Leave(1); \
1.157 + } \
1.158 + }
1.159 +
1.160 +/**
1.161 +* Utility for DEF063276 fix.
1.162 +*/
1.163 +
1.164 +_LIT(KLittleEndianFilename, "z:\\test\\data\\KLittleEndian.dat");
1.165 +_LIT(KBigEndianFilename, "z:\\test\\data\\KBigEndian.dat");
1.166 +
1.167 +// Utility for DEF089572 fix
1.168 +_LIT(KSMS7bitFilename, "z:\\test\\data\\KSMS7bit.dat");
1.169 +
1.170 +void CT_AUTODETECT::ReadDesc(TDes8& aDes, const TDesC& aFilename, RFs& aFs)
1.171 + {
1.172 + RFile file;
1.173 + TInt err = file.Open(aFs, aFilename, EFileRead);
1.174 + test(err == KErrNone);
1.175 + CleanupClosePushL(file);
1.176 +
1.177 + err = file.Read(aDes);
1.178 + test(err == KErrNone);
1.179 + CleanupStack::PopAndDestroy(&file);
1.180 + }
1.181 +
1.182 +///////////////////////////////////////////////////////////////////////////////////////
1.183 +///////////////////////////////////////////////////////////////////////////////////////
1.184 +
1.185 +const TInt KMinimumThresholdForConvertableCharacter=70;
1.186 +
1.187 +/**
1.188 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0548
1.189 +@SYMTestCaseDesc Tests for auto detecting the character set
1.190 + Test for CCnvCharacterSetConverter::AutoDetectCharacterSetL()
1.191 +@SYMTestPriority Medium
1.192 +@SYMTestActions Attempt to determine the character set of the sample text from those supported on the phone
1.193 +@SYMTestExpectedResults Test must not fail
1.194 +@SYMREQ REQ0000
1.195 +*/
1.196 +void CT_AUTODETECT::TestAutodetectL(const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>& aArrayOfCharacterSetsAvailable, const TDesC8& aSample, const TUint& aResult)
1.197 + {
1.198 + TInt Confidence = 0;
1.199 + TUint Character = 0;
1.200 + CCnvCharacterSetConverter::AutoDetectCharacterSetL (Confidence,Character, aArrayOfCharacterSetsAvailable,aSample);
1.201 + test(Character==aResult);
1.202 + INFO_PRINTF1(_L("."));
1.203 + }
1.204 +
1.205 +/**
1.206 +@SYMTestCaseID SYSLIB-CHARCONV-CT-1307
1.207 +@SYMTestCaseDesc Tests for auto detecting the character set
1.208 +@SYMTestPriority Medium
1.209 +@SYMTestActions Tests for CCnvCharacterSetConverter::AutoDetectCharSetL()
1.210 +@SYMTestExpectedResults Test must not fail
1.211 +@SYMREQ REQ0000
1.212 +*/
1.213 +void CT_AUTODETECT::TestAutodetect1L(
1.214 + const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>& aArrayOfCharacterSetsAvailable,
1.215 + const TDesC8& aSample,
1.216 + const TUint& aResult,
1.217 + CCnvCharacterSetConverter* aConverter)
1.218 + {
1.219 + TInt Confidence = 0;
1.220 + TUint Character = 0;
1.221 + aConverter->AutoDetectCharSetL(Confidence,Character, aArrayOfCharacterSetsAvailable,aSample);
1.222 + test(Character==aResult);
1.223 + INFO_PRINTF1(_L("."));
1.224 + }
1.225 +/**
1.226 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0549
1.227 +@SYMTestCaseDesc Tests for CCnvCharacterSetConverter::ConvertibleToCharacterSetL() function
1.228 +@SYMTestPriority Medium
1.229 +@SYMTestActions Tests the likelihood that a sample is encoded in a CharacterSetIdentifier
1.230 +@SYMTestExpectedResults Test must not fail
1.231 +@SYMREQ REQ0000
1.232 +*/
1.233 +void CT_AUTODETECT::TestConvertibleToCharacterL(const TUint aCharsetIdentifier, const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>& aArrayOfCharacterSetsAvailable, const TDesC8& aSample, const TInt flag)
1.234 + {
1.235 + TInt confidence = 0;
1.236 + CCnvCharacterSetConverter::ConvertibleToCharacterSetL(confidence,aCharsetIdentifier, aArrayOfCharacterSetsAvailable, aSample);
1.237 + if (flag)
1.238 + {test(confidence >= KMinimumThresholdForConvertableCharacter );}
1.239 + else
1.240 + {test(confidence < KMinimumThresholdForConvertableCharacter );}
1.241 + }
1.242 +
1.243 +TInt CT_AUTODETECT::TestConvertibleToCharacterReturnResultL(const TUint aCharsetIdentifier, const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>& aArrayOfCharacterSetsAvailable, const TDesC8& aSample)
1.244 + {
1.245 + TInt confidence = 0;
1.246 + CCnvCharacterSetConverter::ConvertibleToCharacterSetL(confidence,aCharsetIdentifier, aArrayOfCharacterSetsAvailable, aSample);
1.247 +
1.248 + return confidence;
1.249 + }
1.250 +
1.251 +void CT_AUTODETECT::TestConvertibleToCharacterWithSpecificResultL(const TUint aCharsetIdentifier, const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>& aArrayOfCharacterSetsAvailable, const TDesC8& aSample, const TInt aResult)
1.252 + {
1.253 + TInt confidence = TestConvertibleToCharacterReturnResultL(aCharsetIdentifier, aArrayOfCharacterSetsAvailable, aSample);
1.254 +
1.255 + test(confidence==aResult);
1.256 + }
1.257 +
1.258 +const TInt KMaxSampleLengthForAutoDetection = 1024;
1.259 +
1.260 +/**
1.261 +This test code uses the method as is used by notepad in \Notepad\LibSrc\NpdUtil.cpp
1.262 +
1.263 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0550
1.264 +@SYMTestCaseDesc Tests to autodetect a character read from file
1.265 +@SYMTestPriority Medium
1.266 +@SYMTestActions Tests to determine the character set of the sample text read from a file
1.267 +@SYMTestExpectedResults Test must not fail
1.268 +@SYMREQ REQ0000
1.269 +*/
1.270 +void CT_AUTODETECT::TestAutoDetectFromFileL(const TDesC16& aFileName, const TUint& aResult )
1.271 + {
1.272 + // get file server session and open file
1.273 + RFile file;
1.274 + RFs fileServerSession;
1.275 + CleanupClosePushL(fileServerSession);
1.276 + User::LeaveIfError(fileServerSession.Connect());
1.277 + User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));
1.278 +
1.279 + // get up to KMaxSampleLengthForAutoDetection bytes of file for autodetect
1.280 + TInt size(0);
1.281 + User::LeaveIfError( file.Size(size) );
1.282 +
1.283 + TBuf8<KMaxSampleLengthForAutoDetection> sample;
1.284 + User::LeaveIfError( file.Read(sample,
1.285 + size > KMaxSampleLengthForAutoDetection ? KMaxSampleLengthForAutoDetection : size) );
1.286 +
1.287 + TInt confidence(0);
1.288 + TUint charset(0);
1.289 +
1.290 + // if the first two bytes say unicode, don't bother with autodetect
1.291 + if ( size >= 2 &&
1.292 + ( ( sample[0] == 0xfe && sample[1] == 0xff ) ||
1.293 + ( sample[0] == 0xff && sample[1] == 0xfe ) ) )
1.294 + {
1.295 + charset = 0; // Unicode
1.296 + }
1.297 + else
1.298 + {
1.299 + //ok, try autodetect, first get available character sets
1.300 + const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>*
1.301 + lists = CCnvCharacterSetConverter::
1.302 + CreateArrayOfCharacterSetsAvailableLC( fileServerSession );
1.303 +
1.304 + // now try AutoDetect
1.305 + CCnvCharacterSetConverter::AutoDetectCharacterSetL(confidence, charset, *lists, sample);
1.306 + CleanupStack::PopAndDestroy(); // filserver
1.307 + }
1.308 +
1.309 + INFO_PRINTF5(_L("file %S charset = 0x%x confidence %d expected 0x%x\n"),
1.310 + &aFileName, charset, confidence, aResult );
1.311 +
1.312 + // check the character set expected was the one autodetected
1.313 + test(charset==aResult);
1.314 +
1.315 + CleanupStack::PopAndDestroy(1); // fileserver
1.316 + }
1.317 +/**
1.318 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0551
1.319 +@SYMTestCaseDesc Tests for conversion of characters read from a file to Unicode
1.320 +@SYMTestPriority Medium
1.321 +@SYMTestActions Logs out number of uncoverted bytes left at end,number of uncovertable characters,
1.322 + index of first byte of first unconvertible character
1.323 +@SYMTestExpectedResults Test must not fail
1.324 +@SYMREQ REQ0000
1.325 +*/
1.326 +void CT_AUTODETECT::TestConvertFromFileL(const TDesC16& aFileName, const TUint& aCharacterSetIdentifier )
1.327 + {
1.328 + // get file server session and open file
1.329 + RFile file;
1.330 + RFs fileServerSession;
1.331 + CleanupClosePushL(fileServerSession);
1.332 + User::LeaveIfError(fileServerSession.Connect());
1.333 + User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));
1.334 +
1.335 + // get up to KMaxSampleLengthForAutoDetection bytes of file for autodetect
1.336 + TInt size(0);
1.337 + User::LeaveIfError( file.Size(size) );
1.338 +
1.339 + TBuf8<KMaxSampleLengthForAutoDetection> sample;
1.340 + User::LeaveIfError( file.Read(sample,
1.341 + size > KMaxSampleLengthForAutoDetection ? KMaxSampleLengthForAutoDetection : size) );
1.342 +
1.343 + INFO_PRINTF3(_L("Comnverting to unicode file %S size = %d \n"),
1.344 + &aFileName, size );
1.345 +
1.346 + TInt NumberOfUnconvertibleCharacters=0;
1.347 + TInt IndexOfFirstByteOfFirstUnconvertibleCharacter=0;
1.348 + TInt state = CCnvCharacterSetConverter::KStateDefault;
1.349 + TBuf16<KMaxSampleLengthForAutoDetection> result;
1.350 +
1.351 + CCnvCharacterSetConverter *Converter = CCnvCharacterSetConverter::NewLC();
1.352 + TRAPD( ConverterErr, Converter->PrepareToConvertToOrFromL( aCharacterSetIdentifier, fileServerSession));
1.353 + if ( ConverterErr!= KErrNone )
1.354 + {
1.355 + INFO_PRINTF3(_L("PrepareToConvertToOrFromL left on file %S ConverterErr = 0x%x \n"),
1.356 + &aFileName, ConverterErr );
1.357 + }
1.358 +
1.359 + TInt bytesLeft = Converter->ConvertToUnicode( result,
1.360 + sample,
1.361 + state,
1.362 + NumberOfUnconvertibleCharacters,
1.363 + IndexOfFirstByteOfFirstUnconvertibleCharacter);
1.364 +
1.365 + INFO_PRINTF2(_L("ConvertToUnicode returned %d unconverted bytes left at the end\n"),bytesLeft );
1.366 + INFO_PRINTF2(_L("NumberOfUnconvertibleCharacters=%d \n"),NumberOfUnconvertibleCharacters);
1.367 + INFO_PRINTF2(_L("IndexOfFirstByteOfFirstUnconvertibleCharacter=%d \n"),IndexOfFirstByteOfFirstUnconvertibleCharacter);
1.368 +
1.369 + CleanupStack::PopAndDestroy(2); // fileserver, CCnvCharacterSetConverter
1.370 +}
1.371 +
1.372 +/**
1.373 +INC056019 SS NTT - Character set recognition is not optimized.
1.374 +To improve a performace old static autodetection method was deprecated
1.375 +and a new AutoDetectCharSet method introduced.
1.376 +
1.377 +@SYMTestCaseID SYSLIB-CHARCONV-CT-1308
1.378 +@SYMTestCaseDesc Performance test for auto detection of characters set
1.379 +@SYMTestPriority Medium
1.380 +@SYMTestActions Tests for the new AutoDetectCharSet() function
1.381 +@SYMTestExpectedResults Test must not fail
1.382 +@SYMREQ REQ0000
1.383 +*/
1.384 +void CT_AUTODETECT::TestAutoDetectionPerformanceL(
1.385 + const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* aArrayOfCharacterSetsAvailable)
1.386 + {
1.387 + TInt i;
1.388 +
1.389 + /////////////////////////////////////////////////////////////////
1.390 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-1308 Testing ten calls to Static AutoDetection "));
1.391 + TTime starttime;
1.392 + starttime.UniversalTime();
1.393 + for (i=0; i<10; i++)
1.394 + {
1.395 + INFO_PRINTF2(_L("\n%d run "),i+1);
1.396 + TestAutodetectL(*aArrayOfCharacterSetsAvailable,KSomeISO, KCharacterSetIdentifierIso88591);
1.397 + }
1.398 + TTime endtime;
1.399 + endtime.UniversalTime();
1.400 + TTimeIntervalMicroSeconds difftime=endtime.MicroSecondsFrom(starttime);
1.401 + INFO_PRINTF2(_L("\nTen Static calls duration =%d microseconds\n\n"), difftime.Int64());
1.402 +
1.403 + /////////////////////////////////////////////////////////////////
1.404 + TInt charsetCnvCount = aArrayOfCharacterSetsAvailable->Count();
1.405 + TInt dllCharsetCnvCount = 0;
1.406 + //Count the number of character set converter dlls.
1.407 + for(i=0;i<charsetCnvCount;++i)
1.408 + {
1.409 + const CCnvCharacterSetConverter::SCharacterSet& charset = aArrayOfCharacterSetsAvailable->At(i);
1.410 + if(charset.NameIsFileName())
1.411 + {
1.412 + ++dllCharsetCnvCount;
1.413 + }
1.414 + }
1.415 + if(dllCharsetCnvCount == 0)
1.416 + {
1.417 + INFO_PRINTF1(_L("No character set converter dlls! Exit subtest.\n"));
1.418 + return;
1.419 + }
1.420 +
1.421 + /////////////////////////////////////////////////////////////////
1.422 + CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
1.423 +
1.424 + /////////////////////////////////////////////////////////////////
1.425 + INFO_PRINTF1(_L("Testing ten calls to optimized AutoDetection. Non-optimal cache size."));
1.426 + converter->SetMaxCacheSize(dllCharsetCnvCount / 2 + 1);
1.427 + //Fill the cache
1.428 + TestAutodetect1L(*aArrayOfCharacterSetsAvailable,KSomeISO, KCharacterSetIdentifierIso88591,converter);
1.429 + //
1.430 + starttime.UniversalTime();
1.431 + for (i=0; i<10; i++)
1.432 + {
1.433 + INFO_PRINTF2(_L("\n%d run "),i+1);
1.434 + TestAutodetect1L(*aArrayOfCharacterSetsAvailable,KSomeISO, KCharacterSetIdentifierIso88591,converter);
1.435 + }
1.436 + endtime.UniversalTime();
1.437 + difftime=endtime.MicroSecondsFrom(starttime);
1.438 + INFO_PRINTF2(_L("\nTen non-static calls duration =%d microseconds\n\n"), difftime.Int64());
1.439 +
1.440 + /////////////////////////////////////////////////////////////////
1.441 + INFO_PRINTF1(_L("Testing ten calls to optimized AutoDetection. Optimal cache size."));
1.442 + converter->SetMaxCacheSize(dllCharsetCnvCount + 1);
1.443 + //Fill the cache
1.444 + TestAutodetect1L(*aArrayOfCharacterSetsAvailable,KSomeISO, KCharacterSetIdentifierIso88591,converter);
1.445 + //
1.446 + starttime.UniversalTime();
1.447 + for (i=0; i<10; i++)
1.448 + {
1.449 + INFO_PRINTF2(_L("\n%d run "),i+1);
1.450 + TestAutodetect1L(*aArrayOfCharacterSetsAvailable,KSomeISO, KCharacterSetIdentifierIso88591,converter);
1.451 + }
1.452 + endtime.UniversalTime();
1.453 + difftime=endtime.MicroSecondsFrom(starttime);
1.454 + INFO_PRINTF2(_L("\nTen non-static calls duration =%d microseconds\n\n"), difftime.Int64());
1.455 +
1.456 + /////////////////////////////////////////////////////////////////
1.457 + CleanupStack::PopAndDestroy(converter);
1.458 + }
1.459 +
1.460 +/**
1.461 +@SYMTestCaseID SYSLIB-CHARCONV-UT-4002
1.462 +@SYMTestCaseDesc Test detection of a UTF-8 character set with and without a BOM.
1.463 +@SYMTestPriority Medium
1.464 +@SYMTestActions Tests for IsCharacterSetUTF8() function
1.465 +@SYMTestExpectedResults Tests must not fail
1.466 +@SYMREQ REQ0000
1.467 +*/
1.468 +//INC118714L
1.469 +void CT_AUTODETECT::TestForUtf8BomL()
1.470 + {
1.471 + INFO_PRINTF1(_L("@SYMTestCaseID:SYSLIB-CHARCONV-UT-4002 Testing BOM in UTF-8"));
1.472 +
1.473 + RFs fs;
1.474 + test(fs.Connect() == KErrNone);
1.475 + CleanupClosePushL(fs);
1.476 +
1.477 + TInt confidenceLevel = 0;
1.478 + TBuf8<255> testData;
1.479 + CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* charsets =
1.480 + CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fs);
1.481 + CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewLC();
1.482 +
1.483 + //No BOM
1.484 +
1.485 + // Ensure that UTF-8 doesn't run over ASCII.
1.486 + INFO_PRINTF1(_L("No BOM, Valid UTF-8 and ASCII String."));
1.487 + TestAutodetect1L(*charsets,_L8("\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64"),
1.488 + KCharacterSetIdentifierAscii,converter);
1.489 +
1.490 + //Length
1.491 + // Verify our original length issue is still gone.
1.492 + INFO_PRINTF1(_L("No BOM, valid UTF-8 string, > 100 chars."));
1.493 + // must be >= 100 characters.
1.494 + testData = _L8("\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x30\x30\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\xce\x9f");
1.495 + TestAutodetect1L(*charsets, testData ,
1.496 + KCharacterSetIdentifierUtf8,converter);
1.497 + confidenceLevel = TestConvertibleToCharacterReturnResultL(KCharacterSetIdentifierUtf8,
1.498 + *charsets,testData );
1.499 + test(confidenceLevel == KUtf8NoBomMaxSuccessConfidenceLevel);
1.500 +
1.501 + INFO_PRINTF1(_L("No BOM, valid UTF-8 string, < 100 chars."));
1.502 + testData = _L8("\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\xce\x9f");
1.503 + TestAutodetect1L(*charsets,testData,
1.504 + KCharacterSetIdentifierUtf8,converter);
1.505 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.506 + *charsets,testData,KUtf8NoBomMinSuccessConfidenceLevel);
1.507 +
1.508 + // Then get a bit more concerned.
1.509 + // One one-byte character overlaps several encodings.
1.510 + INFO_PRINTF1(_L("No BOM, valid UTF-8 string, 1 char."));
1.511 + testData = _L8("\x7D");
1.512 + TestAutodetect1L(*charsets,testData,
1.513 + KCharacterSetIdentifierAscii,converter);
1.514 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.515 + *charsets,testData, KUtf8NoBomMinSuccessConfidenceLevel);
1.516 +
1.517 + INFO_PRINTF1(_L("No BOM, valid UTF-8 string, 0 chars."));
1.518 + testData = _L8("");
1.519 + TestAutodetect1L(*charsets,testData,
1.520 + KCharacterSetIdentifierAscii,converter);
1.521 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.522 + *charsets,testData, KUtf8NoStringConfidenceLevel );
1.523 +
1.524 + INFO_PRINTF1(_L("No BOM (i.e. BOM in middle of string), valid UTF-8 string."));
1.525 + // string is both UTF-8 and ISO 8895-1.
1.526 + testData = _L8("00000000:\xef\xbb\xbf\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64");
1.527 + TestAutodetect1L(*charsets,testData,
1.528 + KCharacterSetIdentifierIso88591,converter);
1.529 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.530 + *charsets,testData, KUtf8NoBomMinSuccessConfidenceLevel);
1.531 +
1.532 +
1.533 + //BOM tests
1.534 +
1.535 + // This text is both GBK and UTF-8 compliant. As it stands now we search
1.536 + // the plug-ins first (incl. GBK). So although it may seem counter-intuititve
1.537 + // it is a correct test.
1.538 + INFO_PRINTF1(_L("With BOM, UTF-8 and GBK string."));
1.539 + testData = _L8("\xef\xbb\xbf\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64");
1.540 + TestAutodetect1L(*charsets,testData,
1.541 + KCharacterSetIdentifierGb18030,converter);
1.542 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.543 + *charsets,testData, KUtf8BomConfidenceLevel);
1.544 +
1.545 + INFO_PRINTF1(_L("With BOM, UTF-8 and GBK string, 4 chars."));
1.546 + testData = _L8("\xef\xbb\xbf\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64");
1.547 + TestAutodetect1L(*charsets,testData,
1.548 + KCharacterSetIdentifierGb18030,converter);
1.549 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.550 + *charsets,testData, KUtf8BomConfidenceLevel);
1.551 +
1.552 + INFO_PRINTF1(_L("BOM, valid UTF-8."));
1.553 + testData = _L8("\xef\xbb\xbf\x7F\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64");
1.554 + TestAutodetect1L(*charsets,testData,
1.555 + KCharacterSetIdentifierUtf8,converter);
1.556 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.557 + *charsets,testData, KUtf8BomConfidenceLevel);
1.558 +
1.559 + INFO_PRINTF1(_L("BOM, valid UTF-8, 4 chars."));
1.560 + testData = _L8("\xef\xbb\xbf\x7F");
1.561 + TestAutodetect1L(*charsets,testData,
1.562 + KCharacterSetIdentifierUtf8,converter);
1.563 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.564 + *charsets,testData, KUtf8BomConfidenceLevel);
1.565 +
1.566 + INFO_PRINTF1(_L("BOM, valid UTF-8, 3 chars."));
1.567 + testData = _L8("\xef\xbb\xbf");
1.568 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.569 + *charsets,testData, KUtf8BomConfidenceLevel);
1.570 +
1.571 + INFO_PRINTF1(_L("BOM, valid UTF-8, 2 chars."));
1.572 + testData = _L8("\xef\xbb");
1.573 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.574 + *charsets,testData, KUtf8NoBomMinSuccessConfidenceLevel);
1.575 +
1.576 + INFO_PRINTF1(_L("BOM, valid UTF-8, 1 char."));
1.577 + testData = _L8("\xef");
1.578 + TestAutodetect1L(*charsets,testData,
1.579 + KCharacterSetIdentifierIso88591,converter);
1.580 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.581 + *charsets,testData, KUtf8NoBomMinSuccessConfidenceLevel);
1.582 +
1.583 + INFO_PRINTF1(_L("Invalid BOM, valid UTF-8."));
1.584 + testData = _L8("\xfe\xff\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64");
1.585 + TestAutodetect1L(*charsets,testData,
1.586 + KCharacterSetIdentifierUnicodeBig,converter);
1.587 + TestConvertibleToCharacterWithSpecificResultL(KCharacterSetIdentifierUtf8,
1.588 + *charsets,testData, KUtf8ConfidenceFailure);
1.589 +
1.590 +
1.591 + CleanupStack::Pop(3); //charsets, converter, fs
1.592 + delete converter;
1.593 + delete charsets;
1.594 + fs.Close();
1.595 +
1.596 + }
1.597 +
1.598 +
1.599 +/**
1.600 +@SYMTestCaseID SYSLIB-CHARCONV-CT-0552
1.601 +@SYMTestCaseDesc AutoDetection of character tests
1.602 +@SYMTestPriority Medium
1.603 +@SYMTestActions Calls up auto detection conversion test functions
1.604 +@SYMTestExpectedResults Test must not fail
1.605 +@SYMREQ REQ0000
1.606 +*/
1.607 +void CT_AUTODETECT::DoE32MainL()
1.608 + {
1.609 + RFs fileServerSession;
1.610 + CleanupClosePushL(fileServerSession);
1.611 + User::LeaveIfError(fileServerSession.Connect());
1.612 + const CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* arrayOfCharacterSetsAvailable=CCnvCharacterSetConverter::CreateArrayOfCharacterSetsAvailableLC(fileServerSession);
1.613 +
1.614 + INFO_PRINTF1(_L("@SYMTestCaseID:SYSLIB-CHARCONV-CT-0552 About to start the AutoDetection\n"));
1.615 + INFO_PRINTF1(_L("Embedded Test Tag\n"));
1.616 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-307 Tests for CCnvCharacterSetConverter::AutoDetectCharSetL() \n"));
1.617 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0548 Test for CCnvCharacterSetConverter::AutoDetectCharacterSetL() \n"));
1.618 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0549 Tests for CCnvCharacterSetConverter::ConvertibleToCharacterSetL() function \n"));
1.619 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0550 Tests to autodetect a character read from file \n"));
1.620 + INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0551 Tests for conversion of characters read from a file to Unicode \n"));
1.621 +
1.622 + TestConvertibleToCharacterL(KCharacterSetIdentifierUtf8,*arrayOfCharacterSetsAvailable,KUTF8,1);
1.623 + TestConvertibleToCharacterL(KCharacterSetIdentifierAscii,*arrayOfCharacterSetsAvailable,KASCII,1);
1.624 + TestConvertibleToCharacterL(KCharacterSetIdentifierUnicodeBig,*arrayOfCharacterSetsAvailable,KUnicode,1);
1.625 + TestConvertibleToCharacterL(KCharacterSetIdentifierUnicodeBig,*arrayOfCharacterSetsAvailable,KUnicode3,1);
1.626 + TestConvertibleToCharacterL(KCharacterSetIdentifierShiftJis,*arrayOfCharacterSetsAvailable,KSJISPhrase,1);
1.627 + TestConvertibleToCharacterL(KCharacterSetIdentifierShiftJis,*arrayOfCharacterSetsAvailable,KSJISPhrase,1);
1.628 + TestConvertibleToCharacterL(KCharacterSetIdentifierGb2312,*arrayOfCharacterSetsAvailable,GB2312B,1);
1.629 + TestConvertibleToCharacterL(KCharacterSetIdentifierEucJpPacked,*arrayOfCharacterSetsAvailable,KEUC2,1);
1.630 + TestConvertibleToCharacterL(KCharacterSetIdentifierEucJpPacked,*arrayOfCharacterSetsAvailable,KEUP,1);
1.631 +
1.632 + TestConvertibleToCharacterL(KCharacterSetIdentifierIso88591,*arrayOfCharacterSetsAvailable,KSomeISO,1);
1.633 + TestConvertibleToCharacterL(KCharacterSetIdentifierIso88591,*arrayOfCharacterSetsAvailable,KISODEF,1);
1.634 + TestConvertibleToCharacterL(KCharacterSetIdentifierCodePage1252,*arrayOfCharacterSetsAvailable,KISODEF,0);
1.635 +
1.636 +
1.637 + TestConvertibleToCharacterL(KCharacterSetIdentifierEucJpPacked,*arrayOfCharacterSetsAvailable,KUTF8,0);
1.638 + TestConvertibleToCharacterL(KCharacterSetIdentifierHz,*arrayOfCharacterSetsAvailable,KASCII,0);
1.639 + TestConvertibleToCharacterL(KCharacterSetIdentifierCodePage1252,*arrayOfCharacterSetsAvailable,KUnicode,0);
1.640 + TestConvertibleToCharacterL(KCharacterSetIdentifierSms7Bit,*arrayOfCharacterSetsAvailable,KUnicode3,0);
1.641 + TestConvertibleToCharacterL(KCharacterSetIdentifierSms7Bit,*arrayOfCharacterSetsAvailable,KSJISPhrase,0);
1.642 + TestConvertibleToCharacterL(KCharacterSetIdentifierSms7Bit,*arrayOfCharacterSetsAvailable,KSMS7InvalidEmail,0);
1.643 + TestConvertibleToCharacterL(KCharacterSetIdentifierSms7Bit,*arrayOfCharacterSetsAvailable,KSMS7ValidEmail,1);
1.644 + TestConvertibleToCharacterL(KCharacterSetIdentifierIso2022Jp,*arrayOfCharacterSetsAvailable,KSJISPhrase,0);
1.645 + TestConvertibleToCharacterL(KCharacterSetIdentifierIso2022Jp,*arrayOfCharacterSetsAvailable,GB2312B,0);
1.646 + TestConvertibleToCharacterL(KCharacterSetIdentifierIso2022Jp,*arrayOfCharacterSetsAvailable,KEUC2,0);
1.647 + TestConvertibleToCharacterL(KCharacterSetIdentifierIso2022Jp,*arrayOfCharacterSetsAvailable,KEUP,0);
1.648 + TestConvertibleToCharacterL(KCharacterSetIdentifierEucJpPacked,*arrayOfCharacterSetsAvailable,KSomeISO,0);
1.649 + TestConvertibleToCharacterL(KCharacterSetIdentifierEucJpPacked,*arrayOfCharacterSetsAvailable,KUnicodeFail,0);
1.650 +
1.651 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KEUP,KCharacterSetIdentifierEucJpPacked);
1.652 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KEUC2,KCharacterSetIdentifierEucJpPacked);
1.653 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KUnicode,KCharacterSetIdentifierUnicodeLittle);
1.654 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KUnicode2,KCharacterSetIdentifierUnicodeLittle);
1.655 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KUnicode3,KCharacterSetIdentifierUnicodeBig);
1.656 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KSJISPhrase,KCharacterSetIdentifierShiftJis);
1.657 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KDodgyShiftJIS,KCharacterSetIdentifierShiftJis);
1.658 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KDodgyShiftJIS2,KCharacterSetIdentifierShiftJis);
1.659 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KDodgyShiftJIS3,KCharacterSetIdentifierShiftJis);
1.660 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KBig5,KCharacterSetIdentifierBig5);
1.661 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KSJIS,KCharacterSetIdentifierShiftJis);
1.662 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KASCII,KCharacterSetIdentifierAscii);
1.663 + TestAutodetectL(*arrayOfCharacterSetsAvailable,SJISNET,KCharacterSetIdentifierShiftJis);
1.664 + TestAutodetectL(*arrayOfCharacterSetsAvailable,BIG5A,KCharacterSetIdentifierBig5);
1.665 + TestAutodetectL(*arrayOfCharacterSetsAvailable,BIG5C,KCharacterSetIdentifierBig5);
1.666 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KUTF8,KCharacterSetIdentifierUtf8);
1.667 + TestAutodetectL(*arrayOfCharacterSetsAvailable,BIG5Corrupt,KCharacterSetIdentifierBig5);
1.668 + TestAutodetectL(*arrayOfCharacterSetsAvailable,BIG5Ahalf,KCharacterSetIdentifierBig5);
1.669 + TestAutodetectL(*arrayOfCharacterSetsAvailable,GB2312B,KCharacterSetIdentifierGb18030);
1.670 + TestAutodetectL(*arrayOfCharacterSetsAvailable,GB2312C,KCharacterSetIdentifierGb18030);
1.671 + TestAutodetectL(*arrayOfCharacterSetsAvailable,GB2312Corrupt,KCharacterSetIdentifierGb18030);
1.672 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KISO, KCharacterSetIdentifierIso88591);
1.673 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KSomeISO, KCharacterSetIdentifierIso88591);
1.674 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KShortUnicode1,KCharacterSetIdentifierUnicodeLittle);
1.675 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KShortUnicode2,KCharacterSetIdentifierUnicodeLittle);
1.676 +
1.677 + // INC086007 (and PDEF088039) - start
1.678 + _LIT8(Kexport,"https://espmg002.ext.nokia.com/push/unifi \nhttps://nam.ext.nokia.com/ \n\nhttp://gutenberg.spiegel.de/doyle/napoleon/Druckversion_napoleon.htm\nhttp://gutenberg.spiegel.de/doyle/baskervi/Druckversion_baske-de.htm\n\nhttp://www.heise.de/newsticker/heise.rdf\nhttp://www.teltarif.de/db/news.rss\nhttp://www.linuxdevices.com/backend/headlines10.rdf\nhttp://www.dpreview.com/news/dpr.rdf\nhttp://planet.maemo.org/rss10.xml\nhttp://www.macnews.de/index.php?_mcnpage=71148\nhttp://www.tecchannel.de/news/feed/complete.rss\nhttp://www.n-tv.de/23.rss\nhttp://www.br-online.de/global/export/dynRdf.jsp?channel=\nhttp://www.wdr.de/xml/newsticker.rdf\nhttp://www.tagesschau.de/newsticker.rdf\nhttp://www.n24.de/rss/?rubrik=home\nhttp://www.n24.de/rss/?rubrik=wirtschaft\nhttp://www.n24.de/rss/?rubrik=politik\nhttp://www.welt.de/z/newsticker/ticker_welt.xml\nhttp://www.ftd.de/static/ticker/ftd-topnews.rdf\nhttp://www.ftd.de/static/container/rss/ftd-rss-1200.rdf\nhttp://www.ftd.de/static/container/rss/ftd-rss-200.rdf\nhttp://www.ftd.de/static/container/rss/ftd-rss-300.rdf\nhttp://rss.cnn.com/rss/cnn_world.rss\nhttp://rss.cnn.com/rss/cnn_tech.rss\nhttp://rss.cnn.com/rss/money_topstories.rss\nhttp://rss.cnn.com/rss/cnn_space.rss\nhttp://news.yandex.ru/index.rss\nhttp://news.yandex.ru/world.rss\nhttp://news.yandex.ru/politics.rss\nhttp://news.yandex.ru/science.rss\nhttp://www.jpost.com/servlet/Satellite?pagename=JPost/Page/RSS&cid=1123495333389\n\n\n\n");
1.679 + TestAutodetectL(*arrayOfCharacterSetsAvailable, Kexport, KCharacterSetIdentifierAscii);
1.680 +
1.681 + // test for DEF089572 - ONB: TAUTODETECT failing on Coverage builds
1.682 + TBuf8<300> buf;
1.683 + ReadDesc(buf, KSMS7bitFilename, fileServerSession);
1.684 + TestAutodetectL(*arrayOfCharacterSetsAvailable, buf, KCharacterSetIdentifierSms7Bit);
1.685 +
1.686 + // INC086007 (and PDEF088039) - end
1.687 +
1.688 + //test for INC037743 - Charconv recognises Little Endian as Big Endian
1.689 +
1.690 + // Fix for DEF063276.
1.691 +
1.692 + ReadDesc(buf, KLittleEndianFilename, fileServerSession);
1.693 + TestAutodetectL(*arrayOfCharacterSetsAvailable,buf, KCharacterSetIdentifierUnicodeLittle);
1.694 +
1.695 + ReadDesc(buf, KBigEndianFilename, fileServerSession);
1.696 + TestAutodetectL(*arrayOfCharacterSetsAvailable,buf, KCharacterSetIdentifierUnicodeBig);
1.697 +
1.698 + // End fix
1.699 +
1.700 + // tests for INC037581 - SS66 - Long .txt note fails to open in msg centre inbox
1.701 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KFinnish, KCharacterSetIdentifierIso88591);
1.702 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KSwedish, KCharacterSetIdentifierIso88591);
1.703 +
1.704 + // tests for INC043016 - AV21 via BTH received TXT file could not be opened
1.705 + TestAutodetectL(*arrayOfCharacterSetsAvailable,KGotcha, KCharacterSetIdentifierAscii); // changed to Ascii from Utf8 as part of INC086007
1.706 +
1.707 + //test for INC037705 read in file and try to autodetect()
1.708 +#ifdef __WINS__
1.709 + TestAutoDetectFromFileL(_L("C:\\test\\data\\finnish.txt"), KCharacterSetIdentifierIso88591);
1.710 + TestAutoDetectFromFileL(_L("C:\\test\\data\\swedish.txt"), KCharacterSetIdentifierIso88591);
1.711 +#else
1.712 + TestAutoDetectFromFileL(_L("Z:\\test\\data\\finnish.txt"), KCharacterSetIdentifierIso88591);
1.713 + TestAutoDetectFromFileL(_L("Z:\\test\\data\\swedish.txt"), KCharacterSetIdentifierIso88591);
1.714 +#endif
1.715 +
1.716 +
1.717 + //test for INC037705: read in file and try to convertToUnicode()
1.718 +#ifdef __WINS__
1.719 + TestConvertFromFileL(_L("C:\\test\\data\\finnish.txt"), KCharacterSetIdentifierIso88591);
1.720 + TestConvertFromFileL(_L("C:\\test\\data\\swedish.txt"), KCharacterSetIdentifierIso88591);
1.721 +#else
1.722 + TestConvertFromFileL(_L("Z:\\test\\data\\finnish.txt"), KCharacterSetIdentifierIso88591);
1.723 + TestConvertFromFileL(_L("Z:\\test\\data\\swedish.txt"), KCharacterSetIdentifierIso88591);
1.724 +#endif
1.725 +
1.726 + TestAutoDetectionPerformanceL(arrayOfCharacterSetsAvailable);
1.727 +
1.728 + TestForUtf8BomL();
1.729 +
1.730 + INFO_PRINTF1(_L("\n"));
1.731 + CleanupStack::PopAndDestroy(2);
1.732 + }
1.733 +
1.734 +
1.735 +CT_AUTODETECT::CT_AUTODETECT()
1.736 + {
1.737 + SetTestStepName(KTestStep_T_AUTODETECT);
1.738 + }
1.739 +
1.740 +TVerdict CT_AUTODETECT::doTestStepL()
1.741 + {
1.742 + SetTestStepResult(EFail);
1.743 +
1.744 + __UHEAP_MARK;
1.745 + TRAPD(error1, DoE32MainL());
1.746 + __UHEAP_MARKEND;
1.747 +
1.748 + if(error1 == KErrNone)
1.749 + {
1.750 + SetTestStepResult(EPass);
1.751 + }
1.752 +
1.753 + return TestStepResult();
1.754 + }
1.755 +