Add some YARD docs to the ebcdic methods
parent
a004c72068
commit
01e37386dd
|
@ -365,21 +365,25 @@ module Text
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Converts US-ASCII to UTF-8, skipping over any characters which don't
|
||||||
|
# convert cleanly. This is a convenience method that wraps
|
||||||
|
# String#encode with non-raising default paramaters.
|
||||||
#
|
#
|
||||||
# Converts US-ASCII and ISO-8859-1 to UTF-8, skipping over
|
# @param str [String] An encodable ASCII string
|
||||||
# any characters which don't convert cleanly.
|
# @return [String] a UTF-8 equivalent
|
||||||
#
|
# @note This method will discard invalid characters
|
||||||
def self.to_utf8(str)
|
def self.to_utf8(str)
|
||||||
str.encode('utf-8', { :invalid => :replace, :undef => :replace, :replace => '' })
|
str.encode('utf-8', { :invalid => :replace, :undef => :replace, :replace => '' })
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# Converts ASCII to EBCDIC
|
|
||||||
#
|
|
||||||
class IllegalSequence < ArgumentError; end
|
class IllegalSequence < ArgumentError; end
|
||||||
|
|
||||||
# A native implementation of the EBCDIC->ASCII table, since it's not available
|
# A native implementation of the ASCII to EBCDIC conversion table, since
|
||||||
# in String#encode
|
# EBCDIC isn't available to String#encode as of Ruby 2.1
|
||||||
|
#
|
||||||
|
# @param str [String] An encodable ASCII string
|
||||||
|
# @return [String] an EBCDIC encoded string
|
||||||
|
# @note This method will raise in the event of invalid characters
|
||||||
def self.to_ebcdic(str)
|
def self.to_ebcdic(str)
|
||||||
new_str = []
|
new_str = []
|
||||||
str.each_byte do |x|
|
str.each_byte do |x|
|
||||||
|
@ -392,8 +396,12 @@ module Text
|
||||||
new_str.join
|
new_str.join
|
||||||
end
|
end
|
||||||
|
|
||||||
# A native implementation of the EBCDIC->ASCII table, since it's not available
|
# A native implementation of the EBCIDC to ASCII conversion table, since
|
||||||
# in String#encode
|
# EBCDIC isn't available to String#encode as of Ruby 2.1
|
||||||
|
#
|
||||||
|
# @param str [String] an EBCDIC encoded string
|
||||||
|
# @return [String] An encodable ASCII string
|
||||||
|
# @note This method will raise in the event of invalid characters
|
||||||
def self.from_ebcdic(str)
|
def self.from_ebcdic(str)
|
||||||
new_str = []
|
new_str = []
|
||||||
str.each_byte do |x|
|
str.each_byte do |x|
|
||||||
|
|
Loading…
Reference in New Issue