aboutsummaryrefslogtreecommitdiff
path: root/src/tests/utf.cpp
blob: 40d4194d2c8d135e190fe7a13d76e2f3e2f34d87 (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
66
67
68
69
70
71
#include <bu/file.h>
#include <bu/string.h>
#include <bu/utfstring.h>
#include <bu/sio.h>

using namespace Bu;

int main()
{
    sio << "Code: " << Bu::__calcHashCode( Bu::UtfString("Hello there") )
        << sio.nl;

    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();
    }
    */
}