Ticket #1671: to_charset_binary.patch
File to_charset_binary.patch, 1.4 KB (added by NotFound, 12 years ago) |
---|
-
src/string/charset/binary.c
147 147 148 148 =item C<static STRING* to_charset(PARROT_INTERP, const STRING *src)> 149 149 150 Converts the STRING C<src> to STRING C<dest> in binary mode. Throws 151 an exception if a suitable conversion function is not found. 150 Converts the STRING C<src> to STRING C<dest> in binary mode. 151 Just a byte image of the string content regardless its charset 152 and encoding. The user is supposed to know what is doing. 152 153 153 154 =cut 154 155 … … 159 160 to_charset(PARROT_INTERP, ARGIN(const STRING *src)) 160 161 { 161 162 ASSERT_ARGS(to_charset) 162 charset_converter_t conversion_func =163 Parrot_find_charset_converter(interp, src->charset, Parrot_binary_charset_ptr);164 163 165 if (conversion_func) 166 return conversion_func(interp, src); 167 168 Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, 169 "to_charset for binary not implemented"); 164 const UINTVAL bytel = src->bufused; 165 STRING *r = Parrot_gc_new_string_header(interp, 0); 166 Parrot_gc_allocate_string_storage(interp, r, bytel); 167 r->strlen = bytel; 168 r->bufused = bytel; 169 r->charset = Parrot_binary_charset_ptr; 170 r->encoding = Parrot_fixed_8_encoding_ptr; 171 mem_sys_memcopy(r->strstart, src->strstart, bytel); 172 return r; 170 173 } 171 174 172 175 /*