Git Product home page Git Product logo

charset_converter's Introduction

Hello there 👋

I am a software developer, with a passion for learning and building stuff. Programming polyglot with a special place in my heart for Rust 🦀 Flutter and TypeScript. Currently working on the world's easiest visual programming language @turbofuro

  • Stack Overflow user
  • Co-organizer of Wrocław 🇵🇱 Java User Group
  • DIY lover - I built my own keyboard from scratch ⌨️
  • 🍺 homebrewer

Occasionally I write something on my blog or speak at a conference, but what a fun ride it is!

Check out my projects and godlike software, manual pages, gists, configs, keybindings and examples.

charset_converter's People

Contributors

benderblog avatar jukqaz avatar lvinci avatar memphisnguyen avatar pr0gramista avatar sgsm74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

charset_converter's Issues

Error on encoding x-IBM1098 and x-IBM1097

When I want to try encode Persian character it show same digit for all characters
Uint8List encoded = await CharsetConverter.encode("x-IBM1098", "سلام");
It shows: 127, 127, 127, 127, 127
It's so weird a digit for different character and when I try to decode this numbers It shows some square icon.

Detecting charset

I have an application that can open user-supplied files of arbitrary encoding.

For this I need to not only decode bytes (as your plugin currently does) but also detect the encoding.

I could create a separate plugin that just detects, but then the flow would look like this:

  1. Read bytes in Dart land
  2. Pass bytes over platform channel to the detector to get the charset
  3. Again pass the bytes over platform channel to your plugin to decode, then send the string back

If the bytes are large then (2) is a big overhead, and it's quite wasteful to separate the detector and the decoder.

Would you be willing to accept a PR that adds detecting capability to your plugin?

I am looking at these libraries to do the actual detection:

So the cost to you and your plugin would be bloat for those who don't need detecting. I understand if you don't want that; then I will make a separate plugin that mostly duplicates your work, and the cost to the community is yet another set of very similar plugins that need to be evaluated (which is not necessarily a bad thing; if someone really doesn't need detecting then your plugin can remain the "slim" option in that case).

Fix Codemagic CI for Windows

Currently, Windows builds are getting stuck on test execution. The example app process does start.

If run manually from PowerShell it doesn't work, but when the same command is executed from Remote Desktop it suddenly works perfectly, which indicates this might have to do something with missing/uninitialized desktop environment/GUI.

ISO-8859-7 specific characters are causing encoding to fail

String encoding = "ISO-8859-7";
var encoded = await CharsetConverter.encode(encoding, line.text);

No matter the encoding used i get this error on ios.
Android works fine.

PlatformException(encoding_failed, Encoding failed, reason unknown, null, null)

Hi i cant flutter esc pos print Kazakh Letters.

Hi i cant flutter esc pos print Kazakh Letters.

Uint8List cash =
        await CharsetConverter.encode(encodPrint, "Қолма-қол ақша салу");

 print_bluetooth_thermal: ^1.0.9  charset_converter: ^2.1.1  esc_pos_utils_plus: ^2.0.2

 Unhandled Exception: PlatformException(encoding_failed, Encoding failed, reason unknown, null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
<asynchronous suspension>
#2      CharsetConverter.encode (package:charset_converter/charset_converter.dart:19:20)
<asynchronous suspension>

Error Kazakh Letters

Hi i cant flutter esc pos print Kazakh Letters.

printer.rawBytes(await CharsetConverter.encode(codeTable, "Круассан с шоколадом "));

esc_pos_printer: ^4.1.0 charset_converter: ^2.1.1 esc_pos_utils: ^1.1.0

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(encoding_failed, Encoding failed, reason unknown, null, null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18) <asynchronous suspension> #2 CharsetConverter.encode (package:charset_converter/charset_converter.dart:19:20) <asynchronous suspension> #3 _WebViewExampleState.printDemoReceipt (package:my_app/main.dart:967:24)

Kotlin plugin version not compatible

Following error occurs while bulding android project:


FAILURE: Build failed with an exception.

  • What went wrong:
    The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher.
    The following dependencies do not satisfy the required version:
    project ':charset_converter' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50

My kotlin version is 1.7.20
Gradle version is 7.3.1

buildscript {
    ext.kotlin_version = '1.7.20'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

Some special charset to use the Windows machine's locale

On Windows, we want to use the current codepage normally described as ANSI codepage, typically to convert codepage specific characters to UTF-8.

Could you please introduce some kind of "ansi" or "auto" or something to specify the current codepage on Windows?

Missing import

Hello,

with this commit: 13adf8e u had remove the import of 'dart:typed_data'.
This import is needed for Uint8list so i cant build projects with the last release.

macOS Support?

Hello. Thank you for developing such an amazing library.

My question is, is it possible to use this library for Flutter apps for macOS?

Regards,

Result of decode http response is null

I try to decode http response bodybyte into UTF-8 at iOS emulator(iPhone 12 Pro Max emulator. (iOS Deployment Target=9.0)).
But result of decode was null.
In android emulator case same code is successful.
So I consider that this issue is only iOS side.

Please confirm this code and if possible please share solution.

import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:html/dom.dart' as dom;
import 'package:http/http.dart' as http;
import 'package:charset_converter/charset_converter.dart';
import 'package:flutter_user_agent/flutter_user_agent.dart';
// skip

String userAgent;
try {
  userAgent = await FlutterUserAgent.getPropertyAsync('userAgent');
  print("userAgent: ${userAgent}");
} on PlatformException {
  userAgent = '<error>';
}
var response = await http.Client().get(Uri.parse("http://news4vip.livedoor.biz/archives/52385788.html"), headers: {'User-Agent': userAgent});
print("Response status: ${response.statusCode}");
print("response.headers: ${response.headers['content-type']}");
String decoded_body_byte = await CharsetConverter.decode("UTF-8", response.bodyBytes);
print("decoded_body_byte: ${decoded_body_byte}"); // This result is null. This is issue.
Uint8List encoded = await CharsetConverter.encode("UTF-8", "【画像】中日「かっこいい」今季のユニホーム発表www");
print("encoded.length: ${encoded.length}");
String decoded_body_byte_only_title = await CharsetConverter.decode("UTF-8", response.bodyBytes.sublist(71, 71 + 78));
print("decoded_body_byte_only_title: ${decoded_body_byte_only_title}");`

The following is the output result of the above code.

`2021-01-23 17:09:29.964984+0900 Runner[89036:14458916] flutter: userAgent: CFNetwork/1209 Darwin/20.2.0 (iPhone iOS/14.3)
2021-01-23 17:09:30.187131+0900 Runner[89036:14458916] flutter: Response status: 200
2021-01-23 17:09:30.190547+0900 Runner[89036:14458916] flutter: response.headers: text/html; charset=utf-8
2021-01-23 17:09:30.195755+0900 Runner[89036:14458916] flutter: decoded_body_byte: null
2021-01-23 17:09:30.197368+0900 Runner[89036:14458916] flutter: encoded.length: 78
2021-01-23 17:09:30.198128+0900 Runner[89036:14458916] flutter: decoded_body_byte_only_title: 【画像】中日「かっこいい」今季のユニホーム発表www

Below is the output result of $ flutter doctor. I would appreciate it if you could answer.

`% flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale ja-JP)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.52.1)
[✓] Connected device (2 available)

! Doctor found issues in 2 categories.`

Linux support?

Hello,

Do you have plans of adding linux support any time soon?

Best regards.

Encode and decode problem

@pr0gramista hi, thank you for this library.
I also need to print windows1250 String on termal printer (slovenian language).
But I have problem with encoding / decoding. This is example:

 String inputString = " čĆžŽšŠ-H-ščđ - in slovenian";
 Uint8List encodedBytes = await CharsetConverter.encode("windows1250", inputString);

//If I send this encodedBytes to printer - printer print correct characters

//But for formating output text on printer I need to send it as a String.

//And if I convert encodedBytes back to String and send it to printer the print characters are wrong:
String decoded = await CharsetConverter.decode("windows-1250", encodedBytes);

Can you please tell me what I am doing wrong here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.