mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Dump non-ASCII char as unsigned
Non-ASCII code may be negative on platforms plain char is signed.
This commit is contained in:
parent
7223c0da15
commit
cf7d07570f
Notes:
git
2022-07-22 12:01:38 +09:00
2 changed files with 16 additions and 1 deletions
|
@ -142,7 +142,7 @@ dump_append_sizet(struct dump_config *dc, const size_t number)
|
|||
}
|
||||
|
||||
static void
|
||||
dump_append_c(struct dump_config *dc, char c)
|
||||
dump_append_c(struct dump_config *dc, unsigned char c)
|
||||
{
|
||||
if (c <= 0x1f) {
|
||||
const unsigned int width = (sizeof(c) * CHAR_BIT / 4) + 5;
|
||||
|
|
|
@ -725,4 +725,19 @@ class TestObjSpace < Test::Unit::TestCase
|
|||
assert_equal '42', out[2]
|
||||
end
|
||||
end
|
||||
|
||||
def test_utf8_method_names
|
||||
name = "utf8_❨╯°□°❩╯︵┻━┻"
|
||||
obj = ObjectSpace.trace_object_allocations do
|
||||
__send__(name)
|
||||
end
|
||||
dump = ObjectSpace.dump(obj)
|
||||
assert_equal name, JSON.parse(dump)["method"], dump
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def utf8_❨╯°□°❩╯︵┻━┻
|
||||
"1#{2}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue