Mercurial > octave
annotate liboctave/wrappers/uniconv-wrappers.h @ 32023:bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
* bootstrap.conf: Add module "uniconv/u16-conv-from-enc".
* liboctave/wrappers/uniconv-wrappers.c, liboctave/wrappers/uniconv-wrappers.h
(octave_u16_conv_from_encoding, octave_u16_conv_from_encoding_strict): Add
wrappers for gnulib function.
* liboctave/util/oct-string.cc, liboctave/util/oct-string.h
(octave::string::u16_to_encoding): Add new function.
* libgui/src/m-editor/file-editor-tab.h: Remove header that is no longer needed.
* libgui/src/m-editor/file-editor-tab.cc
(octave::file_editor_tab::load_file): Use iconv/gnulib functions to load file
editor content from file in any encoding. The interpreter needs to be able to
read these files using the iconv/gnulib functions anyway. And Qt6 can only
convert from UTF-8, UTF-16, UTF-32 or the system locale encoding.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 15 Apr 2023 20:51:50 +0200 |
parents | da2954782945 |
children | 2e484f9f1f18 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30822
diff
changeset
|
3 // Copyright (C) 2017-2023 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
23123
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if ! defined (octave_uniconv_wrappers_h) |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #define octave_uniconv_wrappers_h 1 |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
24104
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
29 #if defined (__cplusplus) |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
30 # include <cstddef> |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
31 # include <cstdint> |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
32 #else |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
33 # include <stddef.h> |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
34 # include <stdint.h> |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
35 #endif |
0d96215c6e7d
add standard system includes needed in wrapper headers
Mike Miller <mtmiller@octave.org>
parents:
23123
diff
changeset
|
36 |
23123
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #if defined __cplusplus |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 extern "C" { |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #endif |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 // Since we omit arguments we don't care about in Octave, these aren't |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 // named with the _wrapper suffix. |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 |
29231
4e196fbb28a5
Set API tags in files in liboctave/wrappers (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28534
diff
changeset
|
44 extern OCTAVE_API uint8_t * |
23123
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_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
|
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 |
29231
4e196fbb28a5
Set API tags in files in liboctave/wrappers (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28534
diff
changeset
|
48 extern OCTAVE_API char * |
23123
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 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
|
50 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
|
51 |
29231
4e196fbb28a5
Set API tags in files in liboctave/wrappers (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28534
diff
changeset
|
52 extern OCTAVE_API char * |
28534
548598760b66
get_ASCII_filename: On Windows, optionally try to convert to the locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
53 octave_u8_conv_to_encoding_strict (const char *tocode, const uint8_t *src, |
548598760b66
get_ASCII_filename: On Windows, optionally try to convert to the locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
54 size_t srclen, size_t *lengthp); |
548598760b66
get_ASCII_filename: On Windows, optionally try to convert to the locale charset.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
55 |
32023
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
56 extern OCTAVE_API uint16_t * |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
57 octave_u16_conv_from_encoding (const char *fromcode, const char *src, |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
58 size_t srclen, size_t *lengthp); |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
59 |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
60 extern OCTAVE_API uint16_t * |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
61 octave_u16_conv_from_encoding_strict (const char *fromcode, const char *src, |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
62 size_t srclen, size_t *lengthp); |
bce1850f8104
gui: Use iconv/gnulib to load editor content from files in any encoding.
Markus Mützel <markus.muetzel@gmx.de>
parents:
32021
diff
changeset
|
63 |
29231
4e196fbb28a5
Set API tags in files in liboctave/wrappers (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28534
diff
changeset
|
64 extern OCTAVE_API char * |
32021
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
65 octave_u16_conv_to_encoding (const char *tocode, const uint16_t *src, |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
66 size_t srclen, size_t *lengthp); |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
67 |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
68 extern OCTAVE_API char * |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
69 octave_u16_conv_to_encoding_strict (const char *tocode, const uint16_t *src, |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
70 size_t srclen, size_t *lengthp); |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
71 |
da2954782945
gui: Use iconv/gnulib to save editor content in non-UTF-8.
Markus Mützel <markus.muetzel@gmx.de>
parents:
31706
diff
changeset
|
72 extern OCTAVE_API char * |
26331
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25512
diff
changeset
|
73 octave_u32_conv_to_encoding_strict (const char *tocode, const uint32_t *src, |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25512
diff
changeset
|
74 size_t srclen, size_t *lengthp); |
5f10217b562d
Use gnulib to check if encoding is possible (bug #55306).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25512
diff
changeset
|
75 |
30822
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
76 extern OCTAVE_API uint8_t * |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
77 octave_u8_conv_from_encoding_offsets |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
78 (const char *fromcode, const char *src, size_t srclen, |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
79 size_t *offsets, size_t *lengthp); |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
80 |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
81 extern OCTAVE_API char * |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
82 octave_u8_conv_to_encoding_offsets |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
83 (const char *tocode, const uint8_t *src, size_t srclen, |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
84 size_t *offsets, size_t *lengthp); |
0826c503f294
Encoding facet based on gnulib uniconv for STL iostreams (bug #61839).
Markus Mützel <markus.muetzel@gmx.de>
parents:
30564
diff
changeset
|
85 |
29231
4e196fbb28a5
Set API tags in files in liboctave/wrappers (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28534
diff
changeset
|
86 extern OCTAVE_API char * u8_from_wchar (const wchar_t *wc); |
25512
7335d44f34b4
Add conversion functions between UTF-8 and wchar_t (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
87 |
29231
4e196fbb28a5
Set API tags in files in liboctave/wrappers (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
28534
diff
changeset
|
88 extern OCTAVE_API wchar_t * u8_to_wchar (const char *u8_char); |
25512
7335d44f34b4
Add conversion functions between UTF-8 and wchar_t (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25054
diff
changeset
|
89 |
23123
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 #if defined __cplusplus |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 } |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 #endif |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 |
c6ca5fe1505c
use wrappers for uniconv functions; style fixes for unicode conv fcns
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 #endif |