diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 00:32:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 00:32:15 +0000 |
commit | 593505ac6f802d2b5bff469425b7c76b65cc9b10 (patch) | |
tree | 92bae2daccfc2c2dd2ec9330240148b8f430ea48 /string.c | |
parent | 4045cb82227e7b97342eb92b17e35f534128e90d (diff) | |
download | ruby-593505ac6f802d2b5bff469425b7c76b65cc9b10.tar.gz |
string.c: respect the actual encoding
* string.c (rb_enc_str_coderange): respect the actual encoding of
if a BOM presents, and scan for the actual code range.
[ruby-core:91662] [Bug #15635]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -655,12 +655,13 @@ rb_enc_str_coderange(VALUE str) if (cr == ENC_CODERANGE_UNKNOWN) { int encidx = ENCODING_GET(str); rb_encoding *enc = rb_enc_from_index(encidx); - if (rb_enc_mbminlen(enc) > 1 && rb_enc_dummy_p(enc)) { + if (rb_enc_mbminlen(enc) > 1 && rb_enc_dummy_p(enc) && + rb_enc_mbminlen(enc = get_actual_encoding(encidx, str)) == 1) { cr = ENC_CODERANGE_BROKEN; } else { cr = coderange_scan(RSTRING_PTR(str), RSTRING_LEN(str), - get_actual_encoding(encidx, str)); + enc); } ENC_CODERANGE_SET(str, cr); } |