Skip to content

Commit

Permalink
Merge pull request #39 from pr0gramista/pre-2.2.0
Browse files Browse the repository at this point in the history
Prepare for 2.2.0
  • Loading branch information
pr0gramista authored Feb 25, 2024
2 parents f136641 + 6e55eaa commit 4914f29
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 142 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Name of your workflow.
name: "Tests"
name: "Checks"
on:
push:
branches:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.2.0
* Linux support (thanks to [BenderBlog](https://github.com/pr0gramista/charset_converter/pull/38))

## 2.1.2
* Fix missing namespace in Android project (thanks to [MemphisNguyen](https://github.com/pr0gramista/charset_converter/pull/36))

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ iOS can also work with charsets with CoreFoundation CFString functions fe. `CFSt

Windows can use [MultiByteToWideChar](https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar) and [WideCharToMultiByte](https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte) from Win32.

Linux can use [libIconv in GLib](https://docs.gtk.org/glib/struct.IConv.html). Since Flutter for Linux use GTK, it is pretty suitable. However, it accept a NUL terminated UTF-8 string (like C string end with`\0`), so in Dart side, String will be dealt by transfering into Uint8List, and add 0 at the end.
Linux can use [libIconv in GLib](https://docs.gtk.org/glib/struct.IConv.html). Since Flutter for Linux use GTK, it is pretty suitable. However, it accept a NUL terminated UTF-8 string (like C string end with`\0`), so in Dart side, String will be dealt by transferring into Uint8List, and add 0 at the end.

## Contributing

Expand Down
2 changes: 0 additions & 2 deletions example/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ final charsetTestCases = [
ConversionTestCase("Big5", "中文abc", "164, 164, 164, 229, 97, 98, 99"),
ConversionTestCase("Big5", "測試", "180, 250, 184, 213"),
ConversionTestCase("EUC-KR", "김치", "177, 232, 196, 161"),
ConversionTestCase("windows1250", "Cześć",
"67, 122, 101, 156, 230"), // failed on linux is predictable
ConversionTestCase("Windows-1250", "Cześć", "67, 122, 101, 156, 230"),
ConversionTestCase("GB2312", "测试", "178, 226, 202, 212"),
ConversionTestCase("GBK", "悯农", "195, 245, 197, 169"),
Expand Down
128 changes: 56 additions & 72 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ packages:
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
charset_converter:
Expand All @@ -31,55 +31,55 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.2"
version: "2.2.0"
clock:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.18.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.6"
equatable:
dependency: transitive
description:
name: equatable
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.0.5"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.flutter-io.cn"
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
version: "6.1.4"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -95,7 +95,7 @@ packages:
description:
name: flutter_lints
sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
flutter_test:
Expand All @@ -113,86 +113,62 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.flutter-io.cn"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
name: lints
sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.flutter-io.cn"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.flutter-io.cn"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.flutter-io.cn"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.10.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.flutter-io.cn"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.8.3"
platform:
dependency: transitive
description:
name: platform
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.flutter-io.cn"
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
url: "https://pub.dev"
source: hosted
version: "3.1.4"
version: "3.1.2"
process:
dependency: transitive
description:
name: process
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
url: "https://pub.flutter-io.cn"
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -203,89 +179,97 @@ packages:
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
super_form:
dependency: "direct main"
description:
name: super_form
sha256: "4de33058b8d2c1e4fd72513785ae9425f589048a6bd20df8a260dec8e5ebd0bf"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
sync_http:
dependency: transitive
description:
name: sync_http
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.3.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.flutter-io.cn"
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "11.10.0"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "0.3.0"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
url: "https://pub.flutter-io.cn"
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.2"
sdks:
dart: ">=3.2.0-0 <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=1.17.0"
4 changes: 2 additions & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void main() {
// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data!.startsWith('Running on:'),
(Widget widget) =>
widget is Text && widget.data!.startsWith('Running on:'),
),
findsOneWidget,
);
Expand Down
11 changes: 5 additions & 6 deletions lib/charset_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ class CharsetConverter {
///
/// When encoding fails either [CharsetConversionError] or [PlatformException] is thrown.
static Future<Uint8List> encode(String charset, String data) async {
// ignore: prefer_typing_uninitialized_variables
late final result;
late final Uint8List? result;

if (Platform.isLinux) {
/// I know it is silly, but GLib string (gchar *) is the same as C's,
/// the end of the string must be '\0'.
///
/// I am bad at C, so I have to dealt it in Dart side:P
// A bit silly, but GLib string (gchar *) is the same as C's, the end of the string must be '\0'.
// We are bad at C so we handle it here.
result = await _channel.invokeMethod('encode', {
"charset": charset,
"data": Uint8List.fromList([...utf8.encode(data), 0]),
Expand Down Expand Up @@ -53,6 +50,8 @@ class CharsetConverter {
static Future<String> decode(String charset, Uint8List data) async {
final result = await _channel.invokeMethod('decode', {
"charset": charset,
// A bit silly, but GLib string (gchar *) is the same as C's, the end of the string must be '\0'.
// We are bad at C so we handle it here.
"data": Platform.isLinux ? Uint8List.fromList([...data, 0]) : data,
});

Expand Down
Loading

0 comments on commit 4914f29

Please sign in to comment.