Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ISO88591Transcoder.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ISO88591Transcoder.cc (C) 2000-2007 */
9/* */
10/* ISO-8859-1 Transcoder from/to UTF-16. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/ISO88591Transcoder.h"
17#include "arcane/utils/Iostream.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28ISO88591Transcoder::
29~ISO88591Transcoder()
30{
31}
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36void ISO88591Transcoder::
37build()
38{
39}
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
45transcodeToUtf16(const Byte* src, Integer src_len, UChar* out)
46{
47 const Byte* src_current = src;
48 const Byte* src_end = src + src_len;
49 while (src_current < src_end)
50 *out++ = *src_current++;
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
57transcodeFromUtf16(const UChar* src, Integer src_len, Byte* out)
58{
59 const UChar* src_current = src;
60 const UChar* src_end = src + src_len;
61 bool has_error = false;
62 while (src_current < src_end) {
63 if (*src_current < 256) {
64 *out++ = Byte(*src_current);
65 }
66 else {
67 // Conversion impossible. Replace with a whitespace character
68 has_error = true;
69 *out++ = 0x1A;
70 }
71 ++src_current;
72 }
73 if (has_error) {
74 cerr << "ARCANE: Bad transcoding from UTF16 to ISO88591\n";
75 }
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
81} // namespace Arcane
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
virtual void transcodeFromUtf16(const UChar *src, Integer src_len, Byte *out)
Translates the source src of length src_len from the UTF-16 format.
virtual void transcodeToUtf16(const Byte *src, Integer src_len, UChar *out)
Translates the source src of length src_len to the UTF-16 format.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:43
unsigned short UChar
Type of a unicode character.
Definition BaseTypes.h:47