Snap! Websites
An Open Source CMS System in C++
#include <string.h>
This function initializes an empty string.
Definition at line 60 of file string.cpp.
Referenced by from_wchar().
-1
)
This function creates a string and initializes it with the specified input string.
The input is considered to be ISO-8859-1 and thus it gets copied in the string as is (see the from_char() function.) If you have UTF-8 data, make sure to use the from_utf8() function instead.
Note that we cannot include '\0' characters in our strings. This function stops at the first null terminator no matter what.
str
pointer can be set to nullptr in which case the string is considered empty.len
parameter.
[in]lenThe length of the string, if -1, expect a '\0'.
Definition at line 89 of file string.cpp.
References from_char().
-1
)
This function creates a string and initializes it with the specified input string.
The input is considered to be UTF-32 or UTF-16 depending on the width of the wchar_t type.
Note that we cannot include '\0' characters in our strings. This function stops at the first null terminator no matter what.
str
pointer can be set to nullptr in which case the string is considered empty.len
parameter.
[in]lenThe length of the string, if -1, expect a '\0'.
Definition at line 117 of file string.cpp.
References from_wchar().
-1
)
This function creates a string and initializes it with the specified input string.
The input is considered to be UTF-32 and thus it gets copied as is.
Note that we cannot include '\0' characters in our strings. This function stops at the first null terminator no matter what.
str
pointer can be set to nullptr in which case the string is considered empty.len
parameter.
[in]lenThe length of the string, if -1, expect a '\0'.
Definition at line 144 of file string.cpp.
References from_as_char(), and STRING_GOOD.
This function copies str in this String.
The input is considered to be ISO-8859-1 and thus it gets copied in the string as is (see the from_char() function.) If you have UTF-8 data, make sure to use the from_utf8() function instead.
Definition at line 166 of file string.cpp.
References from_char().
This function copies str in this String.
The input string is taken as UTF-16 if wchar_t is 2 bytes and as such converts the surrogates (0xD800 to 0xDFFF) to UTF-32 characters as expected. If wchar_t is 4 bytes, the string is copied as is.
Definition at line 185 of file string.cpp.
References from_wchar().
This function copies str in this String.
The input string is taken as UTF-32 and copied as is in its entirety.
Definition at line 200 of file string.cpp.
This function copies an as_char_t string to this String. Since an as_char_t string has the same character type as a String, this copy is straight forward.
The copy stops as soon as a null ('\0') character is found.
str
, in which case the string is considered empty.Definition at line 733 of file string.cpp.
References STRING_GOOD, STRING_INVALID, and valid_character().
Referenced by String().
-1
)
This function concatenate this String and a standard C-string.
This function concatenate this String and a standard wide C-string.
This function concatenate this String and a C-link string made of as_char_t characters. The array must be null terminated (\0).
This function concatenate this String and a C++ string.
This function concatenate this String and a C++ wide string.
This function copies the ISO-8859-1 string pointer by str to this string. The previous string is lost.
If a null character is found, the copy stops.
The len
parameter can be used to limit the length of the copy.
str
, in which case the string is considered empty.Definition at line 588 of file string.cpp.
References STRING_GOOD.
Referenced by operator=(), and String().
-1
)
This function copies a string to this String. In this case the input string is considered to be UTF-8.
If you have an std::string, use the c_str() operation to call this function.
The copy stops as soon as a null ('\0') character is found.
Definition at line 792 of file string.cpp.
References STRING_BAD, STRING_END, STRING_GOOD, STRING_INVALID, and valid_character().
Referenced by from_utf8(), as2js::DecodingFilterDetect::get_char(), as2js::rc_t::get_home(), as2js::Compiler::get_package_filename(), and as2js::rc_t::init_rc().
See the fromt_utf8(char const * str, int len = -1) implementation for additional information.
Definition at line 891 of file string.cpp.
References from_utf8().
-1
)
This function copies a wchar_t string to this String. Internally we only deal with UTF-32 characters. However, this function expects the input to possibly be UTF-16 and converts surrogate characters to UTF-32 as expected in UTF-16. (In other words, this functions works under Linux and MS-Windows.)
str
, in which case the string is considered empty.Definition at line 638 of file string.cpp.
References String(), STRING_BAD, STRING_END, STRING_GOOD, and STRING_INVALID.
Referenced by as2js::Message::operator<<(), operator=(), and String().
This function parses the string to see whether it represents a valid floating pointer number: an integral part, an optional decimal part, and an optional signed exponent.
The sign of the exponent is also itself optional.
Note that this function returns true if the number is an integer in decimal number representation, however, it will return false for hexadecimal numbers. You may also call the is_number() function to know whether a string represents either a decimal number or a floating point number.
Definition at line 1105 of file string.cpp.
Referenced by is_number(), to_float64(), and as2js::Node::to_int64().
This function checks the strings to see whether it represents a valid integer. The function supports decimal and hexadecimal numbers. Octals are not supported because JavaScript does not convert numbers that start with a 0 as if these were octal numbers.
Definition at line 1037 of file string.cpp.
Referenced by is_number(), to_int64(), and as2js::Node::to_int64().
This function checks whether this string represents a number. This means it returns true in the following cases:
Unfortunately, JavaScript does not understand "true", "false", and "null" as numbers (even though isNaN(true), isNaN(false), and isNaN(null) all return true.)
Definition at line 1155 of file string.cpp.
References is_float64(), and is_int64().
A string that is empty is considered false. Any other string is considered true.
Definition at line 1253 of file string.cpp.
Referenced by as2js::Node::to_boolean(), and as2js::Node::to_boolean_type_only().
This function compares an ISO-8859-1 string against this String. If you have a UTF-8 string, make sure to use from_utf8() first and then compare the two String's against each other.
Definition at line 942 of file string.cpp.
This function appends str to this String. The string is viewed as ISO-8859-1. If another format is expected, make sure to use the proper function.
Definition at line 309 of file string.cpp.
This function appends str to this String. The string is viewed as UTF-16 if wchar_t is 2 bytes, and UTF-32 if wchar_t is 4 bytes. If another format is expected, make sure to use the proper function.
Definition at line 329 of file string.cpp.
This function appends str to this String. The string is viewed as UTF-32. If another format is expected, make sure to use the proper function.
Definition at line 347 of file string.cpp.
This function appends str to this String. The string is viewed as ISO-8859-1. If another format is expected, make sure to use the proper function.
Definition at line 364 of file string.cpp.
This function appends str to this String. The string is viewed as UTF-16 if wchar_t is 2 bytes, and UTF-32 if wchar_t is 4 bytes. If another format is expected, make sure to use the proper function.
Definition at line 382 of file string.cpp.
This function append str to this String. The string is viewed as UTF-32. If another format is expected, make sure to use the proper function.
Definition at line 400 of file string.cpp.
This function append c to this String. The character is viewed as UTF-32. If another format is expected, make sure to use the proper function.
Definition at line 417 of file string.cpp.
This function append c to this String. The character is viewed as ISO-8859-1. If another format is expected, make sure to use the proper function.
Definition at line 434 of file string.cpp.
This function append c to this String. The character is viewed as UTF-32. If another format is expected, make sure to use the proper function.
Definition at line 457 of file string.cpp.
References valid_character().
This function copies str in this String. The string is viewed as ISO-8859-1. If another format is expected, make sure to use the proper function.
Definition at line 218 of file string.cpp.
References from_char().
This function copies str in this String. The string is viewed as UTF-16 if wchar_t is 2 bytes, and UTF-32 if wchar_t is 4 bytes. If another format is expected, make sure to use the proper function.
Definition at line 237 of file string.cpp.
References from_wchar().
This function copies str in this String. The string is viewed as ISO-8859-1. If another format is expected, make sure to use the proper function.
Definition at line 256 of file string.cpp.
References from_char().
This function copies str in this String. The string is viewed as UTF-16 if wchar_t is 2 bytes, and UTF-32 if wchar_t is 4 bytes. If another format is expected, make sure to use the proper function.
Definition at line 275 of file string.cpp.
References from_wchar().
This function copies str in this String. The string is viewed as UTF-32. If another format is expected, make sure to use the proper function.
Definition at line 292 of file string.cpp.
This function compares an ISO-8859-1 string against this String. If you have a UTF-8 string, make sure to use from_utf8() first and then compare the two String's against each other.
Definition at line 907 of file string.cpp.
This function makes a copy of this string while removing spaces from the start, the end, and within the string keep a single space.
If the string starts with a number, then only the number is kept.
Definition at line 1400 of file string.cpp.
This function verifies that the string represents a valid floating point number, if so, it converts it to such and returns the result.
If the string does not represent a valid floating point, then the function returns NaN.
Definition at line 1230 of file string.cpp.
References is_float64(), and to_utf8().
Referenced by as2js::Lexer::read_number(), as2js::Node::to_float64(), as2js::Node::to_int64(), and as2js::Node::to_number().
This function verifies that the string represents a valid integer number, if so, it converts it to such and returns the result.
If the string does not represent a valid integer, then the function should return NaN. Unfortunately, there is not NaN integer. Instead it will return zero (0) or it will raise an exception.
Definition at line 1181 of file string.cpp.
References is_int64(), and to_utf8().
Referenced by as2js::Node::to_int64().
This function converts this String in UTF-8 using an std::string and then returns the result.
Definition at line 1343 of file string.cpp.
References valid_character().
Referenced by as2js::StandardOutput::internal_write(), as2js::FileOutput::internal_write(), as2js::Compiler::load_internal_packages(), as2js::FileInput::open(), as2js::FileOutput::open(), as2js::Message::operator<<(), as2js::operator<<(), as2js::Lexer::read_number(), to_float64(), and to_int64().
This function calculates the length necessary to convert the string to UTF-8.
Definition at line 1283 of file string.cpp.
References valid_character().
This function checks all the characters for validity. This is based on a Unicode piece of code that clearly specifies that a certain number of characters just cannot be used (i.e. this includes UTF-16 surrogates, and any value larger than 0x10FFFF or negative numbers.)
Note that the null character '\0' is considered valid and part of the string, however, anything after that character is ignored.
Definition at line 986 of file string.cpp.
References valid_character().
The UTF-32 type is limited in the code points that can be used. This function returns true if the code point of c
is considered valid.
Characters in UTF-32 must be defined between 0 and 0x10FFFF inclusive, except for code points 0xD800 to 0xDFFF which are used as surrogate for UTF-16 encoding.
Definition at line 1015 of file string.cpp.
Referenced by from_as_char(), from_utf8(), as2js::DecodingFilterUTF8::get_char(), as2js::DecodingFilterUTF32LE::get_char(), as2js::DecodingFilterUTF32BE::get_char(), operator+=(), to_utf8(), utf8_length(), and valid().
This function compares an ISO-8859-1 string against a String. If you have a UTF-8 string, make sure to use from_utf8() first and then compare the two String's against each other.
Definition at line 960 of file string.cpp.
This function compares an ISO-8859-1 string against a String. If you have a UTF-8 string, make sure to use from_utf8() first and then compare the two String's against each other.
Definition at line 925 of file string.cpp.
Definition at line 56 of file string.h.
Referenced by as2js::JSON::output().
Definition at line 58 of file string.h.
Referenced by as2js::Lexer::char_type(), as2js::Lexer::escape_sequence(), and as2js::Lexer::read_string().
This document is part of the Snap! Websites Project.
Copyright by Made to Order Software Corp.
Snap! Websites
An Open Source CMS System in C++