nitc: fix calling extern constructors from extern code in separate compiler
[nit.git] / lib / base64.nit
index 9c57166..7b78d78 100644 (file)
@@ -36,6 +36,10 @@ redef class String
        # Encodes the receiver string to base64.
        # By default, uses "=" for padding.
        fun encode_base64 : String do return encode_base64_custom_padding( '=' )
+
+       # Encodes the receiver string to base64 using a custom padding character.
+       #
+       # If using the default padding character `=`, see `encode_base64`.
        fun encode_base64_custom_padding( padding : Char ) : String
        do
                var base64_chars = once base64_chars
@@ -78,6 +82,10 @@ redef class String
        # Decodes the receiver string from base64.
        # By default, uses "=" for padding.
        fun decode_base64 : String do return decode_base64_custom_padding( '=' )
+
+       # Decodes the receiver string to base64 using a custom padding character.
+       #
+       # If using the default padding character `=`, see `decode_base64`.
        fun decode_base64_custom_padding( padding : Char ) : String
        do
                var inverted_base64_chars = once inverted_base64_chars
@@ -87,12 +95,12 @@ redef class String
                var steps = length / 4
                var result_length = steps*3
 
-               var padding_begin = padding.search_index_in( self, 0 )
+               var padding_begin = self.search(padding)
                var padding_count : Int
-               if padding_begin == -1 then
+               if padding_begin == null then
                        padding_count = 0
                else
-                       padding_count = length - padding_begin
+                       padding_count = length - padding_begin.from
                        steps -= 1
                        result_length -= padding_count
                end