X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=utf8%2Futf8-locale.c;h=ff443e17e188cdbcebb5ea3c188d0047bf78c07d;hb=94ba56fcb08f1fd4eff2803ab2a29603fad2c18e;hp=115c66ee7312e66bec78e797abaa4f2cc95bc9e2;hpb=af581cf02cbbed0d24636be0b3533587448e7e0f;p=gedcom-parse.git diff --git a/utf8/utf8-locale.c b/utf8/utf8-locale.c index 115c66e..ff443e1 100644 --- a/utf8/utf8-locale.c +++ b/utf8/utf8-locale.c @@ -1,35 +1,42 @@ /* Encoding utility from UTF-8 to locale and vice versa Copyright (C) 2001, 2002 Peter Verthez - Permission granted to do anything with this file that you want, as long - as the above copyright is retained in all copies. - THERE IS NO WARRANTY - USE AT YOUR OWN RISK + The UTF8 tools 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. + + The Gedcom parser 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 the Gedcom parser library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ /* $Id$ */ /* $Name$ */ -#include "utf8.h" +#include "utf8tools.h" #include #include +#include #include "libcharset.h" static convert_t locale_conv = NULL; -void convert_set_unknown(const char* unknown) -{ - conversion_set_unknown(locale_conv, unknown); -} - -void close_conversion_contexts() +static void close_conversion_contexts() { cleanup_utf8_conversion(locale_conv); } -int open_conversion_contexts() +static int open_conversion_contexts() { assert (locale_conv == NULL); - locale_conv = initialize_utf8_conversion(locale_charset()); + locale_conv = initialize_utf8_conversion(locale_charset(), 0); if (locale_conv) { atexit(close_conversion_contexts); @@ -40,12 +47,19 @@ int open_conversion_contexts() } } +void convert_set_unknown(const char* unknown) +{ + if (!locale_conv) + open_conversion_contexts(); + conversion_set_unknown(locale_conv, unknown); +} + char* convert_utf8_to_locale(const char* input, int *conv_fails) { if (!locale_conv) open_conversion_contexts(); - return convert_from_utf8(locale_conv, input, conv_fails); + return convert_from_utf8(locale_conv, input, conv_fails, NULL); } char* convert_locale_to_utf8(const char* input) @@ -53,5 +67,5 @@ char* convert_locale_to_utf8(const char* input) if (!locale_conv) open_conversion_contexts(); - return convert_to_utf8(locale_conv, input); + return convert_to_utf8(locale_conv, input, strlen(input)); }