-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8559 from xokdvium/dev/fix-char-traits-utf32
util: Replace std::basic_string<unsigned> with std::basic_string<char32_t>
- Loading branch information
Showing
7 changed files
with
17 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include "unescape_string.h" | ||
|
||
std::basic_string<unsigned int> convert_one_string_literal( | ||
const std::string &src) | ||
std::basic_string<char32_t> convert_one_string_literal(const std::string &src) | ||
{ | ||
PRECONDITION(src.size() >= 2); | ||
|
||
|
@@ -28,8 +27,8 @@ std::basic_string<unsigned int> convert_one_string_literal( | |
PRECONDITION(src[src.size() - 1] == '"'); | ||
PRECONDITION(src[2] == '"'); | ||
|
||
std::basic_string<unsigned int> value= | ||
unescape_wide_string(std::string(src, 3, src.size()-4)); | ||
std::basic_string<char32_t> value = | ||
unescape_wide_string(std::string(src, 3, src.size() - 4)); | ||
|
||
// turn into utf-8 | ||
const std::string utf8_value = utf32_native_endian_to_utf8(value); | ||
|
@@ -57,7 +56,7 @@ std::basic_string<unsigned int> convert_one_string_literal( | |
unescape_string(std::string(src, 1, src.size()-2)); | ||
|
||
// pad into wide string | ||
std::basic_string<unsigned int> value; | ||
std::basic_string<char32_t> value; | ||
value.resize(char_value.size()); | ||
for(std::size_t i=0; i<char_value.size(); i++) | ||
value[i]=char_value[i]; | ||
|
@@ -72,7 +71,7 @@ exprt convert_string_literal(const std::string &src) | |
// e.g., something like "asd" "xyz". | ||
// GCC allows "asd" L"xyz"! | ||
|
||
std::basic_string<unsigned int> value; | ||
std::basic_string<char32_t> value; | ||
|
||
char wide=0; | ||
|
||
|
@@ -101,8 +100,7 @@ exprt convert_string_literal(const std::string &src) | |
INVARIANT(j < src.size(), "non-terminated string constant '" + src + "'"); | ||
|
||
std::string tmp_src=std::string(src, i, j-i+1); | ||
std::basic_string<unsigned int> tmp_value= | ||
convert_one_string_literal(tmp_src); | ||
std::basic_string<char32_t> tmp_value = convert_one_string_literal(tmp_src); | ||
value.append(tmp_value); | ||
i=j; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ Author: Daniel Kroening, [email protected] | |
#include <string> | ||
|
||
std::string unescape_string(const std::string &); | ||
std::basic_string<unsigned int> unescape_wide_string(const std::string &); | ||
std::basic_string<char32_t> unescape_wide_string(const std::string &); | ||
|
||
unsigned hex_to_unsigned(const char *, std::size_t digits); | ||
unsigned octal_to_unsigned(const char *, std::size_t digits); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters