File: testIconv.rb

package info (click to toggle)
jruby 1.5.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 46,252 kB
  • ctags: 72,039
  • sloc: ruby: 398,155; java: 169,482; yacc: 3,782; xml: 2,469; ansic: 415; sh: 279; makefile: 78; tcl: 40
file content (23 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'test/minirunit'
test_check "Iconv:"

require 'iconv'

test_exception(Iconv::IllegalSequence) { p Iconv.conv("ASCII", "UTF-8", "ol\303\251") }
test_exception(Iconv::IllegalSequence) { p Iconv.conv("UTF-8", "UTF-8", "\xa4") }
test_exception(Iconv::IllegalSequence) { p Iconv.conv("UTF-8", "UTF-8//IGNORE", "\xa4") }

# FIXME: Java does not support transliteration in core jdk?
#Iconv.iconv("ASCII//TRANSLIT", "UTF-8", "ol\303\251")

# JRUBY-867, make us ignore transliteration stuff since we can't support it

result = Iconv.conv("ISO-8859-1//TRANSLIT", "UTF-8", "ol\303\251")
test_equal("ol\351", result)
result = Iconv.conv("ISO-8859-1//IGNORE", "UTF-8", "ol\303\251")
test_equal("ol\351", result)
result = Iconv.conv("ISO-8859-1//IGNORE//TRANSLIT", "UTF-8", "ol\303\251")
test_equal("ol\351", result)

result = Iconv.conv("UTF-8//IGNORE", "UTF-8", "\xa4")
test_equal("", result)