Code Monkey home page Code Monkey logo

enough_convert's People

Contributors

bobaxix avatar habbas11 avatar moheb2000 avatar robert-virkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

enough_convert's Issues

FormatException: Invalid value in input: \"➢\" / (10146) at index 1204

i am getting this error when copying and pasting text from word into an editable div and trying to write to the database by encoding the data with the enough_convert win1252 codec

it seems the codec doesn't know how to deal with the "➢" character

image
image
image

FormatException: Invalid value in input: \"➢\" / (10146) at index 1204 of \""

#0      BaseEncoder.convert (package:enough_convert/src/base.dart:166:13)
#1      Codec.encode (dart:convert/codec.dart:21:32)
#2      new ParameterValue.text (package:postgres_fork/src/query.dart:313:20)
#3      new ParameterValue (package:postgres_fork/src/query.dart:296:29)
#4      Query._formatSql.<anonymous closure> (package:postgres_fork/src/query.dart:119:20)
#5      Query._prepareSubstitutionValues (package:postgres_fork/src/query.dart:83:13)
#6      Query._formatSql (package:postgres_fork/src/query.dart:115:9)
#7      Query.sendExtended (package:postgres_fork/src/query.dart:149:23)
#8      _PostgreSQLConnectionStateReadyInTransaction.processQuery (package:postgres_fork/src/connection_fsm.dart:376:9)
#9      _PostgreSQLConnectionStateReadyInTransaction.awake (package:postgres_fork/src/connection_fsm.dart:362:14)
#10     _PostgreSQLConnectionStateReadyInTransaction.onEnter (package:postgres_fork/src/connection_fsm.dart:355:12)
#11     PostgreSQLConnection._transitionToState (package:postgres_fork/src/connection.dart:302:41)
#12     PostgreSQLConnection._readData (package:postgres_fork/src/connection.dart:337:11)
#13     _rootRunUnary (dart:async/zone.dart:1399:47)
#14     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
#15     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
#16     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#17     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#18     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#19     _StreamController._add (dart:async/stream_controller.dart:648:7)
#20     _StreamController.add (dart:async/stream_controller.dart:596:5)
#21     _Socket._onData (dart:io-patch/socket_patch.dart:2324:41)
#22     _rootRunUnary (dart:async/zone.dart:1407:13)
#23     _CustomZone.runUnary (dart:async/zone.dart:1300:19)
#24     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1209:7)
#25     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#26     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#27     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#28     _StreamController._add (dart:async/stream_controller.dart:648:7)
#29     _StreamController.add (dart:async/stream_controller.dart:596:5)
#30     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1849:33)
#31     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1322:14)
#32     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#33     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#34     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
#35     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)

Support chunked conversion

Currently no chunked conversion is supported, it would be nice to suport decoder/encoder .startChunkedConversion(...).

How to convert from Windows1251 String to UTF String?

This is more of a question rather than an issue, but hopefully someone can answer me.

I am loading the HTML from a Russian webpage using http package into a String variable like so:

String html = await http.Client().get(Uri.parse(url)).body;

The website encoding is Windows1251. So for example html variable can have text such as "Êàêèå". This is what I see when I print the variable.

So my question is: How do I convert that string to Cyrillic characters in Unicode encoding which should result in "Какие"?

I tried this:

import 'dart:convert';
import 'package:enough_convert/enough_convert.dart';

void main() {
  final html = "Êàêèå";
  final encoded = const Windows1251Codec().encode(html);
  final converted = const Utf8Codec().decode(encoded);
  print(converted);
}

But I get an error on this line: final encoded = const Windows1251Codec().encode(html);:

FormatException: Invalid value in input: "Ê" / (202) at index 0 of "Êàêèå"

Essentially what I would like to do is to convert "Êàêèå" to "Какие". You can do this on the website https://convertcyrillic.com. Here is the screenshot:

Screenshot 2023-09-13 at 12 57 32 PM

So how do I do this programmatically in Dart?

how to use this with 'http' or 'dio' package to send formdata?

hello there ~
I want send datas using gbk encoding
but http package not support gbk

var datas = {
   "message" : "你好"
}
final res = await http.post(_uri, body: datas, encoding: GbkCodec());

OUTPUT:
Unhandled Exception: FormatException: Unsupported encoding "gbk".

add StreamTransformer suport

add StreamTransformer suport

import 'dart:convert';
import 'dart:io';

import 'package:csv/csv.dart';
import 'package:enough_convert/enough_convert.dart';

void main(List<String> args) async {
  final input = new File(
          'C:/MyDartProjects/notifis/notifis_backend/db/planilhas/CIP 2012.csv')
      .openRead();

  final codec = const Windows1252Codec(allowInvalid: false);
  final stream =  await input.transform(codec).transform(LineSplitter());
  await for (var lineString in stream) {
    var rowsAsListOfValues =
        CsvToListConverter(fieldDelimiter: ';').convert(lineString);
    var lineCsv = rowsAsListOfValues.first;
    print(lineCsv.map((e) => '$e').join(' | '));
  }

  exit(0);
}

image

Do not modify input data when decoding

Changing the input data is more efficient but is prone to result in side effects. Instead the data should be copied, when and if this becomes necessary.

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.