Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a185d74f5aec
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bc9ae5b50a24
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on May 25, 2016

  1. Copy the full SHA
    0546037 View commit details
  2. Copy the full SHA
    16ff516 View commit details
  3. Copy the full SHA
    bc9ae5b View commit details
Original file line number Diff line number Diff line change
@@ -44,17 +44,10 @@
exclude_tests.rb: |
failures = { KernelTest: [:test_silence_stream,
:test_quietly],
InflectorTest: [:test_titleize_mixture_to_title_case_14],
LoadPathsTest: [:test_uniq_load_paths],
LoggerTest: [:test_buffer_multibyte],
MultibyteCharsExtrasTest: [:test_titleize_should_be_unicode_aware,
:test_titleize_should_not_affect_characters_that_do_not_case_fold],
TransliterateTest: [:test_transliterate_should_allow_a_custom_replacement_char,
:test_transliterate_should_approximate_ascii,
:test_transliterate_should_work_with_custom_i18n_rules_and_uncomposed_utf8],
StringInflectionsTest: [:test_string_parameterized_no_separator,
:test_string_parameterized_normal,
:test_string_parameterized_underscore],
TimeZoneTest: :test_map_srednekolymsk_to_tzinfo }
6 changes: 6 additions & 0 deletions spec/ruby/core/array/pack/shared/unicode.rb
Original file line number Diff line number Diff line change
@@ -23,6 +23,12 @@
].should be_computed_by(:pack, "U")
end

it "constructs strings with valid encodings" do
str = [0x85].pack("U*")
str.should == "\xc2\x85"
str.valid_encoding?.should be_true
end

it "encodes UTF-8 max codepoints" do
[ [[0x10000], "\xf0\x90\x80\x80"],
[[0xfffff], "\xf3\xbf\xbf\xbf"],
Original file line number Diff line number Diff line change
@@ -285,8 +285,8 @@ public static boolean isUTF8ValidOneByte(byte b) {
public static boolean isUTF8ValidTwoBytes(byte... bytes) {
assert bytes.length == 2;

if (bytes[0] >= 0xc2 && bytes[0] <= 0xdf) {
return bytes[1] >= 0x80 && bytes[1] <= 0xbf;
if ((bytes[0] & 0xff) >= 0xc2 && (bytes[0] & 0xff) <= 0xdf) {
return (bytes[1] & 0xff) >= 0x80 && (bytes[1] & 0xff) <= 0xbf;
}

return false;
@@ -295,21 +295,21 @@ public static boolean isUTF8ValidTwoBytes(byte... bytes) {
public static boolean isUTF8ValidThreeBytes(byte... bytes) {
assert bytes.length == 3;

if (bytes[0] < 0xe0 || bytes[0] > 0xef) {
if ((bytes[0] & 0xff) < 0xe0 || (bytes[0] & 0xff) > 0xef) {
return false;
}

if (bytes[2] < 0x80 || bytes[2] > 0xbf) {
if ((bytes[2] & 0xff) < 0x80 || (bytes[2] & 0xff) > 0xbf) {
return false;
}

if (bytes[1] >= 0x80 || bytes[2] <= 0xbf) {
if (bytes[0] == 0xe0) {
return bytes[1] >= 0xa0;
if ((bytes[1] & 0xff) >= 0x80 || (bytes[2] & 0xff) <= 0xbf) {
if ((bytes[0] & 0xff) == 0xe0) {
return (bytes[1] & 0xff) >= 0xa0;
}

if (bytes[0] == 0xed) {
return bytes[1] <= 0x9f;
if ((bytes[0] & 0xff) == 0xed) {
return (bytes[1] & 0xff) <= 0x9f;
}

return true;
@@ -321,25 +321,25 @@ public static boolean isUTF8ValidThreeBytes(byte... bytes) {
public static boolean isUTF8ValidFourBytes(byte... bytes) {
assert bytes.length == 4;

if (bytes[3] < 0x80 || bytes[3] > 0xbf) {
if ((bytes[3] & 0xff) < 0x80 || (bytes[3] & 0xff) > 0xbf) {
return false;
}

if (bytes[2] < 0x80 || bytes[2] > 0xbf) {
if ((bytes[2] & 0xff) < 0x80 || (bytes[2] & 0xff) > 0xbf) {
return false;
}

if (bytes[0] < 0xf0 || bytes[0] > 0xf4) {
if ((bytes[0] & 0xff) < 0xf0 || (bytes[0] & 0xff) > 0xf4) {
return false;
}

if (bytes[1] >= 0x80 || bytes[2] <= 0xbf) {
if (bytes[0] == 0xf0) {
return bytes[1] >= 0x90;
if ((bytes[1] & 0xff) >= 0x80 || (bytes[2] & 0xff) <= 0xbf) {
if ((bytes[0] & 0xff) == 0xf0) {
return (bytes[1] & 0xff) >= 0x90;
}

if (bytes[0] == 0xf4) {
return bytes[1] <= 0x8f;
if ((bytes[0] & 0xff) == 0xf4) {
return (bytes[1] & 0xff) <= 0x8f;
}

return true;