annotate liboctave/wrappers/uniconv-wrappers.c @ 23123:c6ca5fe1505c

use wrappers for uniconv functions; style fixes for unicode conv fcns * boostrap.conf (gnulib_modules): Include localcharset, uniconv/u8-conv-from-enc, and uniconv/u8-conv-to-enc in the list. Remove libunistring from the list. * liboctave/wrappers/localcharset-wrapper.c, liboctave/wrappers/localcharset-wrapper.h, liboctave/wrappers/uniconv-wrappers.c, liboctave/wrappers/uniconv-wrappers.h: New files. * liboctave/wrappers/module.mk: Update. * strfns.cc: Include uniconv-wrappers.h, not uniconv. Assume uniconv functions are available (provided by gnulib). (F__native2unicode__, F__unicode2native__): Use wrapper functions. Simplify. (F__unicode2native__): Return uint8 array. * native2unicode.m, unicode2native.m: Style fixes. Update tests. Use assert directly, not testif. Use error <> ..., not fail.
author John W. Eaton <jwe@octave.org>
date Tue, 31 Jan 2017 13:51:42 -0500
parents
children 194eb4bd202b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23123
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2017 John W. Eaton
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 (at your option) any later version.
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 GNU General Public License for more details.
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 // The conversion functions are provided by gnulib. We don't include
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 // gnulib headers directly in Octave's C++ source files to avoid
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 // problems that may be caused by the way that gnulib overrides standard
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 // library functions.
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #if defined (HAVE_CONFIG_H)
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 # include "config.h"
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #endif
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "uniconv.h"
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include "uniconv-wrappers.h"
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 uint8_t *
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 octave_u8_conv_from_encoding (const char *fromcode, const char *src,
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 size_t srclen, size_t *lengthp)
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 {
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 return u8_conv_from_encoding (fromcode, iconveh_question_mark,
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 src, srclen, NULL, NULL, lengthp);
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 }
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 extern char *
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 octave_u8_conv_to_encoding (const char *tocode, const uint8_t *src,
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 size_t srclen, size_t *lengthp)
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 {
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 return u8_conv_to_encoding (tocode, iconveh_question_mark,
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 src, srclen, NULL, NULL, lengthp);
c6ca5fe1505c use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 }