string_converter

String type converter for Dart

  • UTF8 <-> UTF16
  • UTF8 <-> UTF32
  • UTF8 <-> Binary
  • UTF8 <-> Octal

Example

final converter = StringConverter();
String text = "Hello";

// Convert utf8 to utf16
String utf16 = converter.toUTF16(text);
// 0048 0065 006c 006c 006f

// Convert utf8 to binary
String binary = converter.toOctal(text);
// 110 145 154 154 157

// Convert utf16 to utf8
String utf8 = converter.toUTF8(utf16);
// Hello

You can use the extension method directly on the string too

print("hello".toUTF16());
// 0048 0065 006c 006c 006f

Usage

You can remove space with args space

"hello".toUTF16(space: false);
// 00480065006c006c006f

You can make sure all bytes are there bits long with args format

"5".toBinary();                 // 110101
"5".toBinary(format: true);     // 00110101

Libraries

binary
binary_to_utf8
converter
octal
octal_to_utf8
utf8
utf8_to_any_base
utf8_to_utf16
utf8_to_utf32
utf16
utf32
utf_to_utf8