use a char32_t character in the base Stream class

Add an operator<<(char32_t) to the Stream class, char32_t will be used
as a main character instead of a wchar_t (this is needed on systems
where sizeof(wchar_t) is equal to 2).

while here:
- add to utf8:
  size_t wide_to_int(const Stream & stream, size_t stream_index, int & res, bool & correct)
  template<typename StreamType, typename OutputFunction> bool wide_to_output_function(StreamType & buffer, OutputFunction output_function, int mode = 1)
  template<typename OutputFunction> bool wide_to_output_function_by_index(const Stream & stream, OutputFunction output_function, int mode)
- add to convert/misc:
  bool try_esc_to_tex(char32_t c, pt::Stream & out)
  bool try_esc_to_html(char32_t c, pt::Stream & out)
This commit is contained in:
2024-05-31 23:11:11 +02:00
parent 2689c9fece
commit c0838de3a4
10 changed files with 365 additions and 46 deletions

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2012-2023, Tomasz Sowa
* Copyright (c) 2012-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -177,6 +177,7 @@ public:
TextStreamBase & operator<<(char);
TextStreamBase & operator<<(unsigned char);
TextStreamBase & operator<<(char32_t);
TextStreamBase & operator<<(wchar_t); // no surrogate pairs are used
TextStreamBase & operator<<(bool);
TextStreamBase & operator<<(short);
@@ -893,6 +894,16 @@ return *this;
}
template<typename char_type, size_t stack_size, size_t heap_block_size>
TextStreamBase<char_type, stack_size, heap_block_size> &
TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(char32_t v)
{
int_to_stream(static_cast<int>(v), *this);
return *this;
}
template<typename char_type, size_t stack_size, size_t heap_block_size>
TextStreamBase<char_type, stack_size, heap_block_size> &
TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(wchar_t v)
@@ -1310,7 +1321,7 @@ TextStreamBase<char_type, stack_size, heap_block_size>::fill_up_if_needed(wchar_
/*!
this function converts an UTF-8 stream into wide stream or wide string
this function converts an UTF-8 stream into a wide stream or a wide string
(is declared in utf8/utf8.h)
input: