aboutsummaryrefslogtreecommitdiff
path: root/src/tests/utf.cpp
blob: 3418e680e5e7363593c2f16542388ee24b78f16c (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()
{
	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();
	}
	*/
}