Use #b shortcut instead of #force_encoding (#31059).

Patch by Pavel Rosický.


git-svn-id: http://svn.redmine.org/redmine/trunk@17992 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2019-03-20 01:36:44 +00:00
parent 26509e7f4c
commit 606e75d12d
14 changed files with 32 additions and 40 deletions

View File

@@ -36,9 +36,9 @@ class PdfTest < ActiveSupport::TestCase
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_1, encoding)
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_2, encoding)
txt_3 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(utf8_txt_3, encoding)
assert_equal (+"?\x91\xd4").force_encoding("ASCII-8BIT"), txt_1
assert_equal (+"?\x91\xd4?").force_encoding("ASCII-8BIT"), txt_2
assert_equal (+"??\x91\xd4?").force_encoding("ASCII-8BIT"), txt_3
assert_equal "?\x91\xd4".b, txt_1
assert_equal "?\x91\xd4?".b, txt_2
assert_equal "??\x91\xd4?".b, txt_3
assert_equal "ASCII-8BIT", txt_1.encoding.to_s
assert_equal "ASCII-8BIT", txt_2.encoding.to_s
assert_equal "ASCII-8BIT", txt_3.encoding.to_s
@@ -47,7 +47,7 @@ class PdfTest < ActiveSupport::TestCase
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_en
str1 = "Texte encod\xE9 en ISO-8859-1"
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, 'UTF-8')
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, 'UTF-8')
assert_equal "ASCII-8BIT", txt_1.encoding.to_s
@@ -58,7 +58,7 @@ class PdfTest < ActiveSupport::TestCase
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_ja
str1 = "Texte encod\xE9 en ISO-8859-1"
str2 = (+"\xe9a\xe9b\xe9c\xe9d\xe9e test").force_encoding("ASCII-8BIT")
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
encoding = ( RUBY_PLATFORM == 'java' ? "SJIS" : "CP932" )
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, encoding)
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, encoding)
@@ -72,7 +72,7 @@ class PdfTest < ActiveSupport::TestCase
["CP932", "SJIS"].each do |encoding|
set_fixtures_attachments_directory
str2 = (+"\x83e\x83X\x83g").force_encoding("ASCII-8BIT")
str2 = "\x83e\x83X\x83g".b
a1 = Attachment.find(17)
a2 = Attachment.find(19)