@@ -365,21 +365,25 @@ def self.to_raw(str)
365365 return str
366366 end
367367
368+ # Converts US-ASCII to UTF-8, skipping over any characters which don't
369+ # convert cleanly. This is a convenience method that wraps
370+ # String#encode with non-raising default paramaters.
368371 #
369- # Converts US-ASCII and ISO-8859-1 to UTF-8, skipping over
370- # any characters which don't convert cleanly.
371- #
372+ # @param str [String] An encodable ASCII string
373+ # @return [String] a UTF-8 equivalent
374+ # @note This method will discard invalid characters
372375 def self . to_utf8 ( str )
373376 str . encode ( 'utf-8' , { :invalid => :replace , :undef => :replace , :replace => '' } )
374377 end
375378
376- #
377- # Converts ASCII to EBCDIC
378- #
379379 class IllegalSequence < ArgumentError ; end
380380
381- # A native implementation of the EBCDIC->ASCII table, since it's not available
382- # in String#encode
381+ # A native implementation of the ASCII to EBCDIC conversion table, since
382+ # EBCDIC isn't available to String#encode as of Ruby 2.1
383+ #
384+ # @param str [String] An encodable ASCII string
385+ # @return [String] an EBCDIC encoded string
386+ # @note This method will raise in the event of invalid characters
383387 def self . to_ebcdic ( str )
384388 new_str = [ ]
385389 str . each_byte do |x |
@@ -392,8 +396,12 @@ def self.to_ebcdic(str)
392396 new_str . join
393397 end
394398
395- # A native implementation of the EBCDIC->ASCII table, since it's not available
396- # in String#encode
399+ # A native implementation of the EBCIDC to ASCII conversion table, since
400+ # EBCDIC isn't available to String#encode as of Ruby 2.1
401+ #
402+ # @param str [String] an EBCDIC encoded string
403+ # @return [String] An encodable ASCII string
404+ # @note This method will raise in the event of invalid characters
397405 def self . from_ebcdic ( str )
398406 new_str = [ ]
399407 str . each_byte do |x |
0 commit comments