summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--enc/utf_16be.c28
-rw-r--r--enc/utf_16le.c22
-rw-r--r--test/ruby/test_utf16.rb55
4 files changed, 108 insertions, 9 deletions
@@ -1,3 +1,15 @@
Wed Jan 30 12:06:43 2008 Tadayoshi Funaba <[email protected]>
* bignum.c (rb_cstr_to_inum): '0_2' is a valid representatin.
@@ -29,8 +29,9 @@
#include "regenc.h"
-#define UTF16_IS_SURROGATE_FIRST(c) (c >= 0xd8 && c <= 0xdb)
-#define UTF16_IS_SURROGATE_SECOND(c) (c >= 0xdc && c <= 0xdf)
static const int EncLen_UTF16[] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -55,7 +56,28 @@ static int
utf16be_mbc_enc_len(const UChar* p, const OnigUChar* e ARG_UNUSED,
OnigEncoding enc ARG_UNUSED)
{
- return EncLen_UTF16[*p];
}
static int
@@ -29,8 +29,9 @@
#include "regenc.h"
-#define UTF16_IS_SURROGATE_FIRST(c) (c >= 0xd8 && c <= 0xdb)
-#define UTF16_IS_SURROGATE_SECOND(c) (c >= 0xdc && c <= 0xdf)
static const int EncLen_UTF16[] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -52,10 +53,23 @@ static const int EncLen_UTF16[] = {
};
static int
-utf16le_mbc_enc_len(const UChar* p, const OnigUChar* e ARG_UNUSED,
OnigEncoding enc ARG_UNUSED)
{
- return EncLen_UTF16[*(p+1)];
}
static int
@@ -48,8 +48,59 @@ EOT
# tests start
def test_utf16be_valid_encoding
- s = "\xd8\x00\xd8\x00".force_encoding("utf-16be")
- assert_equal(false, s.valid_encoding?, "#{encdump s}.valid_encoding?")
end
def test_strftime