aboutsummaryrefslogtreecommitdiff
path: root/src/tests/utf.cpp
blob: 01bac7ed99fa56c7bd83a7c5a3c2bf9f29567de7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bu/file.h>
#include <bu/string.h>
#include <bu/utfstring.h>

int main( int argc, char *argv[] )
{
	Bu::File fIn("utf8.in", Bu::File::Read );
	Bu::String sUtf8;
	char buf[4096];
	while( !fIn.isEos() )
	{
		int iAmnt = fIn.read( buf, 4096 );
		sUtf8.append( buf, iAmnt );
	}
	Bu::UtfString us( sUtf8, Bu::UtfString::Utf8 );
	us.debug();
	{
		Bu::File fOut("utf8.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf8 );
	}
	{
		Bu::File fOut("utf16.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf16 );
	}
	{
		Bu::File fOut("utf16le.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf16le );
	}
	{
		Bu::File fOut("utf16be.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf16be );
	}
	{
		Bu::File fOut("utf32.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf32 );
	}
	{
		Bu::File fOut("utf32le.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf32le );
	}
	{
		Bu::File fOut("utf32be.out", Bu::File::WriteNew );
		us.write( fOut, Bu::UtfString::Utf32be );
	}

	/*
	argc--, argv++;

	for( char **sFile = argv; *sFile; sFile++ )
	{
		Bu::File fIn( *sFile, Bu::File::Read );
		Bu::String sUtf8;
		char buf[4096];
		while( !fIn.isEos() )
		{
			int iAmnt = fIn.read( buf, 4096 );
			sUtf8.append( buf, iAmnt );
		}
		Bu::UtfString us( sUtf8, Bu::UtfString::Utf16 );

		us.debug();
	}
	*/
}