encoding.iconv #
fn create_utf_string_with_bom #
fn create_utf_string_with_bom(src []u8, utf_type string) []u8
create_utf_string_with_bom will create a utf8/utf16/utf32 string with BOM header for utf8, it will prepend 0xEFBBBF to the src
for utf16le, it will prepend 0xFFFE to the src
for utf16be, it will prepend 0xFEFF to the src
for utf32le, it will prepend 0xFFFE0000 to the src
for utf32be, it will prepend 0x0000FEFF to the src
fn encoding_to_vstring #
fn encoding_to_vstring(bytes []u8, fromcode string) !string
encoding_to_vstring converts the given bytes
using fromcode
encoding, to a V string (encoded with UTF-8) tips: use iconv --list
check for supported encodings
fn read_file_encoding #
fn read_file_encoding(path string, encoding string) !string
read_file_encoding reads the file in path
with encoding
and returns the contents
fn remove_utf_string_with_bom #
fn remove_utf_string_with_bom(src []u8, utf_type string) []u8
remove_utf_string_with_bom will remove a utf8/utf16/utf32 string's BOM header for utf8, it will remove 0xEFBBBF from the src
for utf16le, it will remove 0xFFFE from the src
for utf16be, it will remove 0xFEFF from the src
for utf32le, it will remove 0xFFFE0000 from the src
for utf32be, it will remove 0x0000FEFF from the src
fn vstring_to_encoding #
fn vstring_to_encoding(str string, tocode string) ![]u8
vstring_to_encoding convert V string str
to tocode
encoding string tips: use iconv --list
check for supported encodings
fn write_file_encoding #
fn write_file_encoding(path string, text string, encoding string, bom bool) !
write_file_encoding write_file convert text
into encoding
and writes to a file with the given path
. If path
already exists, it will be overwritten. For encoding
in UTF8/UTF16/UTF32, if bom
is true, then a BOM header will write to the file.