/* Generated automatically by jlpp - do not edit. */ #include static jakelib::lang::String* jakelib2_strings[] = {null, null, null, null, null, null, null, null, null, null}; // "conv = ByteToCharConverter::getDefault(): " static jchar chars_jakelib2_str_0[] = {99,111,110,118,32,61,32,66,121,116,101,84,111,67,104,97,114,67,111,110,118,101,114,116,101,114,58,58,103,101,116,68,101,102,97,117,108,116,40,41,58,32}; // "ByteToCharConverter::getConverter(\"" static jchar chars_jakelib2_str_1[] = {66,121,116,101,84,111,67,104,97,114,67,111,110,118,101,114,116,101,114,58,58,103,101,116,67,111,110,118,101,114,116,101,114,40,34}; // "\"): " static jchar chars_jakelib2_str_2[] = {34,41,58,32}; // "ISO8859_2" static jchar chars_jakelib2_str_3[] = {73,83,79,56,56,53,57,95,50}; // "ISO8859_2" static jchar chars_jakelib2_str_4[] = {73,83,79,56,56,53,57,95,50}; // "latin3" static jchar chars_jakelib2_str_5[] = {108,97,116,105,110,51}; // "cyrillic" static jchar chars_jakelib2_str_6[] = {99,121,114,105,108,108,105,99}; // "latin1" static jchar chars_jakelib2_str_7[] = {108,97,116,105,110,49}; // "ASCII" static jchar chars_jakelib2_str_8[] = {65,83,67,73,73}; // "utf8" static jchar chars_jakelib2_str_9[] = {117,116,102,56}; #line 1 "EncodingTest.jlc" // -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: EncodingTest.jlc,v 1.15 2003/09/26 15:55:26 florian Exp $ */ #include "Test.h" #include #include #include using namespace jakelib::lang; using namespace jakelib::text::enc; using namespace jakelib::io; using namespace jakelib::util; char* encoderNames[] = {"ISO8859_1", "latin1", "l2", "ISO-8859-20", null}; String& operator+ (String& a, Object& b) { String* n = &a; n = n->plus(&b); return *n; } String& operator+ (String* a, Object& b); String& operator+ (String& a, Object* b) { String* n = &a; n = n->plus(b); return *n; } void toUnicode(String* encoding, jbyte* input) { String str(input, encoding); printf("toUnicode(\"%s\", \"%s\"):\n", encoding->latin1(), input); System::out->println(&str); // int len = strlen(input); // ByteToCharConverter* conv = ByteToCharConverter::getConverter(encoding); // jchar* converted = (jchar*) malloc(sizeof(jchar) * len); // conv->convert((jbyte*) str, 0, len, converted, 0, len); // for (int idx = 0; idx < len; idx++) // System::out->println(String(" ").plus(Integer::toHexString(input[idx] & 0xff))->plus(" -> ") // ->plus(Integer::toHexString(str.charAt(idx)))->plus(", ")); System::out->println(); } // void fromUnicode(String* encoding, String* input) // { // printf("fromUnicode(\"%s\", \"%s\"):\n", encoding->latin1(), input->latin1()); // CharToByteConverter* conv = CharToByteConverter::getConverter(encoding); // ByteArray ba; // conv->convert(input->getChars(), 0, input->length(), &ba); // printf(" => \""); // for (int idx = 0; idx < ba.size(); idx++) // printf("%c", ba.get(idx)); // printf("\"\n"); // } void encodingTest() { char* str_001 = "0123 abcdef äÄöÖüÜß"; try { ByteToCharConverter* conv = ByteToCharConverter::getDefault(); System::out->println(JAKELIB_ONDEMAND(jakelib2_strings[0], new jakelib::lang::String(chars_jakelib2_str_0, 0, 42))->plus(conv)); for (int idx = 0; encoderNames[idx] != null; idx++) { try { System::out->println(JAKELIB_ONDEMAND(jakelib2_strings[1], new jakelib::lang::String(chars_jakelib2_str_1, 0, 35)) ->plus(encoderNames[idx])->plus(JAKELIB_ONDEMAND(jakelib2_strings[2], new jakelib::lang::String(chars_jakelib2_str_2, 0, 4))) ->plus(ByteToCharConverter::getConverter(encoderNames[idx]))); } catch (Exception *e) { System::out->println(e); } } toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[3], new jakelib::lang::String(chars_jakelib2_str_3, 0, 9)), "0123 abcdef §ÛÝ"); toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[4], new jakelib::lang::String(chars_jakelib2_str_4, 0, 9)), "0123 abcdef äÄöÖüÜß"); toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[5], new jakelib::lang::String(chars_jakelib2_str_5, 0, 6)), "0123 abcdef äÄöÖüÜß"); toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[6], new jakelib::lang::String(chars_jakelib2_str_6, 0, 8)), "0123 abcdef äÄöÖüÜß"); toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[7], new jakelib::lang::String(chars_jakelib2_str_7, 0, 6)), "0123 abcdef äÄöÖüÜß"); toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[8], new jakelib::lang::String(chars_jakelib2_str_8, 0, 5)), "0123 abcdef äÄöÖüÜß"); toUnicode(JAKELIB_ONDEMAND(jakelib2_strings[9], new jakelib::lang::String(chars_jakelib2_str_9, 0, 4)), "Interessieren Sie sich für die optimale Gestaltung des Außenbereiches rund um Ihr Eigenheim? Ob Möbel, Fensterrahmen oder ganze Räume - hier finden Sie nützliche Tipps und Ideen zur Renovierung alter Gegenstände, "); //fromUnicode(`"utf8"`, new String("0123 abcdef äÄöÖüÜß", "latin1")); //fromUnicode(`"ascii"`, new String("0123 abcdef äÄöÖüÜß", "latin1")); } catch (Exception *e) { System::out->println(e); } }