Sha256: 4786b4fc8c6ba4a59a55cf091b4c7b1bab74604240b2bbd77650f69db789f913
Contents?: true
Size: 746 Bytes
Versions: 16
Compression:
Stored size: 746 Bytes
Contents
class NSString # converts an NSString instance into a base64 string, using UTF8 encoding or # a user specified encoding. # @todo Support NSDataBase64EncodingOptions options - easy to add, but I want # to add specs, too, and a hash format (e.g. line_length: 64 => # NSDataBase64Encoding64CharacterLineLength). def to_base64(enc=NSUTF8StringEncoding) encoded = self.dataUsingEncoding(enc) encoded.to_base64 end # factory method to convert a base64 string into NSString, using UTF8 or a # user specified encoding. def self.from_base64(base64_str, enc=NSUTF8StringEncoding) data = NSData.from_base64(base64_str.dataUsingEncoding(NSASCIIStringEncoding)) NSString.alloc.initWithData(data, encoding:enc) end end
Version data entries
16 entries across 16 versions & 1 rubygems