aboutsummaryrefslogtreecommitdiffstats
path: root/enc/utf_16be.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 05:30:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 05:30:25 +0000
commit7e3e79d0833953f8243e304a86a96b7e41a310a6 (patch)
tree8d1b62223325305b297a0caa6fd6b158e667c0be /enc/utf_16be.c
parent3a4c2bc034a4205ac7116c69ee39de02defb6d17 (diff)
downloadruby-7e3e79d0833953f8243e304a86a96b7e41a310a6.tar.gz
* enc/utf_16{be,le}.c (utf16{be,le}_mbc_to_code): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/utf_16be.c')
-rw-r--r--enc/utf_16be.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/enc/utf_16be.c b/enc/utf_16be.c
index d6e2c953b7..1e33c2ec7d 100644
--- a/enc/utf_16be.c
+++ b/enc/utf_16be.c
@@ -108,9 +108,8 @@ utf16be_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED,
OnigCodePoint code;
if (UTF16_IS_SURROGATE_FIRST(*p)) {
- code = ((((p[0] - 0xd8) << 2) + ((p[1] & 0xc0) >> 6) + 1) << 16)
- + ((((p[1] & 0x3f) << 2) + (p[2] - 0xdc)) << 8)
- + p[3];
+ code = ((((p[0] << 8) + p[1]) & 0x03ff) << 10)
+ + (((p[2] << 8) + p[3]) & 0x03ff) + 0x10000;
}
else {
code = p[0] * 256 + p[1];