string_converter 0.0.4 copy "string_converter: ^0.0.4" to clipboard
string_converter: ^0.0.4 copied to clipboard

discontinued
outdated

This package enables you to easily convert string characters in many formats to their value.

string_converter #

Best String type converter for Dart

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

Getting Started #

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  string_converter:

Next we need to install this

# Dart
pub get

# Flutter
flutter packages get

In your library add the following import:

import 'package:string_converter/converter.dart';

Usage #

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

// Convert utf8 to utf16
String utf16 = converter.toUTF16(text);
// \u0048\u0065\u006c\u006c\u006f

// Convert utf8 to utf32
String utf32 = converter.toUTF32(text);
// u+00000048u+00000065u+0000006cu+0000006cu+0000006f

// Convert utf8 to binary
String binary = converter.toBinary(text);
// 0x010010000x011001010x011011000x011011000x01101111

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

You can use the extension method directly on the string too

print("hello".toUTF16());
// print \u0048\u0065\u006c\u006c\u006f

You can remove \u , u+ and 0x using the args remove

print(utf8.toUTF16(remove: true));
// print 0048 0065 006c 006c 006f

print(utf8.toUTF32(remove: true));
// print 00000048 00000065 0000006c 0000006c 0000006f

print(utf8.toBinary(remove: true));
// print 01001000 01100101 01101100 01101100 01101111
0
likes
40
pub points
41%
popularity

Publisher

unverified uploader

This package enables you to easily convert string characters in many formats to their value.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on string_converter