string_converter 0.0.4 string_converter: ^0.0.4 copied to clipboard
This package enables you to easily convert string characters in many formats to their value.
import 'package:string_converter/converter.dart';
void main() {
StringConverter converter = StringConverter();
String text = "Hello";
// Convert utf8 to utf16
String utf16 = converter.toUTF16(text);
print(utf16);
// \u0048\u0065\u006c\u006c\u006f
// Convert utf8 to utf32
String utf32 = converter.toUTF32(text);
print(utf32);
// u+00000048u+00000065u+0000006cu+0000006cu+0000006f
// Convert utf8 to binary
String binary = converter.toBinary(text);
print(binary);
// 0x010010000x011001010x011011000x011011000x01101111
// Convert utf16 to utf8
String utf8 = converter.toUTF8(utf16);
print(utf8);
// Hello
// You can also call the extension method directly on the input
// print(binary.toUTF8());
// print Hello
// You can remove \u
// print(utf8.toUTF16(remove: true));
// print 0048 0065 006c 006c 006f
// You can remove u+
// print(utf8.toUTF32(remove: true));
// print 00000048 00000065 0000006c 0000006c 0000006f
// You can remove 0x
// print(utf8.toBinary(remove: true));
// print 01001000 01100101 01101100 01101100 01101111
}