153 if(b >= 0xC0 && b <= 0xDF)
158 else if(b >= 0xE0 && b <= 0xEF)
163 else if(b >= 0xF0 && b <= 0xF7)
179 for(
size_t i(1); i < l; ++i)
182 if(b < 0x80 || b > 0xBF)
188 c = (c << 6) | (b & 0x3F);
227 if(c >= 0xD800 && c < 0xDC00)
229 f_lead_surrogate = c;
232 else if(c >= 0xDC00 && c <= 0xDFFF)
234 if(f_lead_surrogate == 0)
240 c = (((
static_cast<as_char_t>(f_lead_surrogate) & 0x03FF) << 10) | (static_cast<as_char_t>(c) & 0x03FF)) + 0x10000;
241 f_lead_surrogate = 0;
243 else if(f_lead_surrogate != 0)
246 f_lead_surrogate = 0;
429 if(bom == 0x0000FEFF)
435 else if(bom == 0xFFFE0000)
441 else if((bom >> 16) == 0xFEFF)
447 else if((bom >> 16) == 0xFFFE)
453 else if((bom & 0xFFFFFF00) == 0xEFBBBF00)
490 c = f_filter->getc();
584 if(c > 0 && c < 0x110000)
698 return static_cast<char_t>(c) & 255;
734 std::string utf8(filename.
to_utf8());
735 f_file.open(utf8.c_str());
736 if(!f_file.is_open())
757 return static_cast<char_t>(c) & 255;
859 internal_write(data);
896 msg <<
"I/O error: could not write to output.";
932 std::string utf8(filename.
to_utf8());
933 f_file.open(utf8.c_str());
934 if(!f_file.is_open())
960 msg <<
"I/O error: could not write to output.";
virtual void internal_write(String const &data)
Write to the output file.
bool open(String const &filename)
Open the output file.
std::shared_ptr< DecodingFilter > pointer_t
std::string to_utf8() const
Convert a string to UTF-8 and return the result.
as_char_t next_char(as_char_t c)
Decode a UTF-16 character.
virtual as_char_t get_char()
Decode UTF-16 in Little Endian format.
virtual as_char_t get_char()
Get the next ISO-8859-1 character.
StandardOutput()
Initializes the standard output object.
virtual void internal_write(String const &data)
Write a string to standard output.
void write(String const &data)
Write data to this output stream.
void reset_counters(counter_t line=DEFAULT_COUNTER)
Reset the counter.
virtual as_char_t get_char()
Get the next UTF-8 character.
as_char_t getc()
Retrieve the next character.
virtual ~DecodingFilter()
Destructor.
conversion_result_t from_utf8(char const *str, int len=-1)
Copy a UTF-8 string to this String.
virtual as_char_t get_char()=0
virtual as_char_t get_char()
Read the next character in any format.
Position & get_position()
Get the position object of the input object.
virtual as_char_t get_char()
Decode UTF-32 in Little Endian format.
The AlexScript to JavaScript namespace.
virtual as_char_t get_char()
Decode UTF-32 in Big Endian format.
String const & get_string() const
Retrieve a copy of the output string.
virtual as_char_t get_char()
Decode UTF-16 in Big Endian format.
void set_filename(String const &filename)
Set the filename being read.
virtual void internal_write(String const &data)
Write to the output string.
void putc(byte_t c)
Push one byte in the decoder.
static bool valid_character(as_char_t c)
Check whether a character is considered valid.