Giter VIP home page Giter VIP logo

convert's Introduction

Dart CI pub package package publisher

Contains encoders and decoders for converting between different data representations. It's the external counterpart of the dart:convert SDK library, and contains less-central APIs and APIs that need more flexible versioning.

convert's People

Contributors

aaronlademann-wf avatar athomas avatar brianquinlan avatar chalin avatar dantup avatar dependabot[bot] avatar devoncarew avatar franklinyow avatar jakemac53 avatar jonasfj avatar kevmoo avatar lrhn avatar matanlurey avatar mosuem avatar natebosch avatar nex3 avatar pq 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

convert's Issues

Handle control characters of accent marks

Hi, I can't find a solution when decoding a json with accent marks. I have this small json

{ "aString": "carpeta sin título" }

As you can see, the word "título" has an accent mark, really common in Spanish.
When I try to run this code through decode I get the following exception:
FormatException: Control character in string

The decode function is really simple:
return json.decode(jsonString);

Any ideas?

jsonDecode returns String, not List

Steps to Reproduce

  1. Use jsonDecoder with List

Logs

https://paste.xeu100.com/?49310cd9a8bff62f#mUK+5HYLomwYfg4pyQLl3ukmkq8/REXAReAGny8nCVc=

Analyzing xid...

   info - This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: AccountElement._accountId, AccountElement._email, AccountElement._website - lib\elements\AccountElement.dart:3:7 -
          must_be_immutable
   info - The value of the field '_accountId' isn't used - lib\elements\AccountElement.dart:5:7 - unused_field
   info - This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: AuthenticatorElement._authenticators, AuthenticatorElement._index - lib\elements\AuthenticatorElement.dart:8:7 -
          must_be_immutable
   info - This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: AuthenticatorList._authenticators - lib\elements\AuthenticatorList.dart:4:7 - must_be_immutable
   info - This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: NavBarElement._currentPage - lib\elements\NavBarElement.dart:3:7 - must_be_immutable
   info - This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: AccountPage._storage, AccountPage._authenticatorsController - lib\pages\AccountPage.dart:8:7 - must_be_immutable
   info - This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: CreateAuthenticatorPage._secret, CreateAuthenticatorPage._nameController, CreateAuthenticatorPage._secretController,
          CreateAuthenticatorPage._digitsController, CreateAuthenticatorPage._periodController - lib\pages\CreateAuthenticatorPage.dart:6:7 - must_be_immutable

7 issues found. (ran in 4.7s)
[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [Version 10.0.17763.615], locale en-US)
    • Flutter version 1.7.8+hotfix.3 at D:\ProgramStorage\Applications\Flutter
    • Framework revision b712a172f9 (10 days ago), 2019-07-09 13:14:38 -0700
    • Engine revision 54ad777fd2
    • Dart version 2.4.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at C:\Users\liamr\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • Java binary at: C:\Users\liamr\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\183.5692245\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.4)
    • Android Studio at C:\Users\liamr\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\183.5692245
    • Flutter plugin version 37.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[!] IntelliJ IDEA Ultimate Edition (version 2019.1)
    • IntelliJ at C:\Users\liamr\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\191.7479.19
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

Please note that the variables given to it are correct (checked many times)

Support short-hand for creating codecs/converters

Lots of Dart and Flutter users don't even know about package:convert or dart:convert, or when they do it seems difficult to get started - most code samples I've seen folks write static functions in the form of T convert<S, T>(S input) and ignore these packages.

Could we consider adding some simple short-hand classes/functions to make use easier?

  • A MapConverter that uses a backing Map<S, T> to do simple conversions:
class MapConverter<S, T> implements Converter<S, T> {
  const MapCodec(Map<S, T> map) => ...
}

final hexToName = const MapConverter(const {
  0x00: 'Zero',
  0x01: 'One',
  0x02: 'Two',
});

main() {
  print(hexToName.convert(0x01)); // Outputs 'One'.
}
  • A top-level asConverter<S, T>(S Func1<T> function)
main() {
  var /*Converter<int, String>*/ hexToName = asConverter((int value) {
    switch (value) {
      case 0x00: return 'Zero';
      ...
    }
  });
}
  • A top-level asCodec<S, T>(Converter<S, T> encoder, Converter<T, S> decoder)
main() {
  var /*Codec<int, String>*/ hexCodec = asCodec(hexToName, nameToHex);
}

Uncaught Error: Converting object to an encodable object failed: Instance of 'MappedListIterable<int, String>'

Hi,

I have an issue with mapped iterables, the conversion fails with the error:

Uncaught Error: Converting object to an encodable object failed: Instance of 'MappedListIterable<int, String>'

Here it is a sample code to reproduce the issue:

import 'dart:convert';

void main() {
  final Iterable<int> items = [1,2];
  final items2 = items.map((i) => i.toString()); 
  print(jsonEncode(items2));
}

for now to make it working I simply have to add a .toList() after the mapping.

null safety conflict with dart test

The follwing minimum pub spec:

name: test_null

environment:
  sdk: '>=2.12.0-0 <3.0.0'

dependencies:
  convert: ^3.0.0-nullsafety.0

dev_dependencies:
  test: ^1.16.0-nullsafety.12

Causes the version solver to fail with:

The current Dart SDK version is 2.12.0-29.10.beta.

Because shelf_static >=0.1.0+1 <0.2.8 requires SDK version >=1.0.0 <2.0.0 or >=2.0.0-dev.55.0 <2.0.0 and no versions of shelf_static match >0.2.8 <0.3.0, shelf_static >=0.1.0+1 <0.2.8-∞ or >0.2.8 <0.3.0 is forbidden.
And because shelf_static 0.2.8 depends on convert >=1.0.0 <3.0.0, shelf_static >=0.1.0+1 <0.3.0 requires convert >=1.0.0 <3.0.0.
Because no versions of test match >1.16.0-nullsafety.12 <2.0.0 and test 1.16.0-nullsafety.12 depends on shelf_static ^0.2.6, test ^1.16.0-nullsafety.12 requires shelf_static ^0.2.6.
Thus, test ^1.16.0-nullsafety.12 requires convert >=1.0.0 <3.0.0.
So, because test_null depends on both convert ^3.0.0-nullsafety.0 and test ^1.16.0-nullsafety.12, version solving failed.

jsonEncode error when convert with Int64 instance.

The data from MongoDB this data contains a value Int64 type.
This data can't convert to json via jsonEncode function.
The error message is:

Converting object to an encodable object failed: Instance of 'Int64'

Is it a bug or not support?

Dart 2 runtime failures in tests

When running tests in dart 2 mode, see the following

type 'List' is not a subtype of type 'List' of 'chunk' where...
type 'List' is not a subtype of type 'List' of 'chunk' where
List is from dart:core
List is from dart:core
int is from dart:core
package:convert/src/byte_accumulator_sink.dart ByteAccumulatorSink.addSlice
../../tdart/convert/test/byte_accumulator_sink_test.dart 43:10 main.

Json is not getting decode. Tested and it is valid json, Please suggest ways to parse this json.

{ "pageNumber": 0, "pageCount": 0, "transactionId": "126cf723-1d57-4f49-8fb2-072b7c23ec1e", "entries": [ { "content": "{\"resourceType\":\"Bundle\",\"id\":\"DRiefcase_2021-03-15__ManjoorKapoor_Pres-13116\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2021-01-20T04:51:59.1497479Z\",\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/DocumentBundle\"],\"security\":[{\"system\":\"http:\\/\\/terminology.hl7.org\\/CodeSystem\\/v3-Confidentiality\",\"code\":\"V\",\"display\":\"veryrestricted\"}]},\"identifier\":{\"system\":\"http:\\/\\/hip.in\",\"value\":\"242590bb-b122-45d0-8eb2-883392297ee1\"},\"type\":\"document\",\"timestamp\":\"2021-03-15T16:12:43.2682813Z\",\"entry\":[{\"fullUrl\":\"Composition/DRF2021-03-15-13163\",\"resource\":{\"resourceType\":\"Composition\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2021-01-20T04:51:59.1497479Z\",\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/DiagnosticReportRecord\"]},\"language\":\"en-IN\",\"text\":{\"status\":\"generated\",\"div\":\"<divxmlns=\\\"http:\\/\\/www.w3.org\\/1999\\/xhtml\\\"><h4>NarrativewithDetails<\\/h4>\\r<p><b>id:<\\/b>1<\\/p>\\r\\t<p><b>status:<\\/b>final<\\/p>\\r\\t<p><b>category:<\\/b>Computerizedtomographyservice(Details:{http:\\/\\/snomed.info\\/sct}code'310128004'='Computerizedtomographyservice')<\\/p>\\r\\t<p><b>subject:<\\/b>ManjoorKapoor.GeneratedSummary:id:1;MedicalRecordNumber=1234(System:{https:\\/\\/healthid.ndhm.gov.in\\/});active;ManjoorKapoor;ph:8905929811(HOME);gender:male;birthDate:2001-01-01<\\/p>\\r\\t<p><b>issued:<\\/b>2020-07-09<\\/p>\\r\\t<p><b>performer:<\\/b>XYZLabPvt.Ltd.<\\/p>\\r\\t<p><b>resultInterpreter:<\\/b>ManjoorKapoor.GeneratedSummary:id:1;MedicalLicensenumber=7601003178999(System:{doctor.ndhm.gov.in})<\\/p>\\t\\t\\t\\t\\t\\t<h3>DiagnosticReportforManjoorKapoorissued9-July202014:26<\\/h3>\\t\\t\\t\\t\\t\\t<pre>code:CTofhead-neckImagingStudy:HEADandNECKCTDICOMimagingstudyConclusion:CTbrains:largetumorsphenoid\\/clivus.<\\/pre>\\t\\t\\t\\t\\t\\t<p>XYZLabPvt.Ltd.,Incsigned:ManjoorKapoorRadiologist<\\/p>\\t\\t\\t\\t\\t<\\/div>\"},\"identifier\":{\"system\":\"https:\\/\\/ndhm.in\\/phr\",\"value\":\"5d42bc8e-b26f-4b6d-835c-a18458e84957\"},\"status\":\"final\",\"type\":{\"coding\":[{\"system\":\"http:\\/\\/snomed.info\\/sct\",\"code\":\"721981007\",\"display\":\"Diagnosticstudiesreport\"}],\"text\":\"DiagnosticReport\"},\"subject\":{\"reference\":\"Patient/d08d5007-f6fd-48a6-9e47-52ffe4b95da6\"},\"date\":\"2017-05-27T11:46:09+05:30\",\"author\":[{\"reference\":\"Practitioner/ManjoorKapoor\"}],\"title\":\"DiagnosticReport\",\"section\":[{\"title\":\"Computedtomographyimagingreport\",\"code\":{\"coding\":[{\"system\":\"http:\\/\\/snomed.info\\/sct\",\"code\":\"4261000179100\",\"display\":\"Computedtomographyimagingreport\"}]},\"entry\":[{\"reference\":\"DiagnosticReport/DRF2021-03-15-13163\",\"type\":\"DiagnosticReport\"},{\"reference\":\"DocumentReference/DRF2021-03-15-13163\",\"type\":\"DocumentReference\"}]}]}},{\"fullUrl\":\"Patient/d08d5007-f6fd-48a6-9e47-52ffe4b95da6\",\"resource\":{\"resourceType\":\"Patient\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2021-03-15T16:12:43.2682813Z\",\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/Patient\"]},\"text\":{\"status\":\"generated\",\"div\":\"<divxmlns=\\\"http:\\/\\/www.w3.org\\/1999\\/xhtml\\\">ManjoorKapoor<\\/div>\"},\"identifier\":[{\"type\":{\"coding\":[{\"system\":\"http:\\/\\/terminology.hl7.org\\/CodeSystem\\/v2-0203\",\"code\":\"MR\",\"display\":\"Medicalrecordnumber\"}]},\"system\":\"https:\\/\\/healthid.ndhm.gov.in\",\"value\":\"22-7225-4829-5255\"}],\"name\":[{\"text\":\"ManjoorKapoor\"}],\"telecom\":[{\"system\":\"phone\",\"value\":\"8905929811\",\"use\":\"home\"}],\"gender\":\"male\",\"birthDate\":\"2001-01-01\"}},{\"fullUrl\":\"Practitioner/ManjoorKapoor\",\"resource\":{\"resourceType\":\"Practitioner\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2021-03-15T16:12:43.2682813Z\",\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/Practitioner\"]},\"text\":{\"status\":\"generated\",\"div\":\"<divxmlns=\\\"http:\\/\\/www.w3.org\\/1999\\/xhtml\\\">ManjoorKapoor<\\/div>\"},\"identifier\":[{\"type\":{\"coding\":[{\"system\":\"http:\\/\\/terminology.hl7.org\\/CodeSystem\\/v2-0203\",\"code\":\"MD\",\"display\":\"MedicalLicensenumber\"}]},\"system\":\"https:\\/\\/doctor.ndhm.gov.in\",\"value\":\"21-1521-3828-3227\"}],\"name\":[{\"text\":\"ManjoorKapoor\"}]}},{\"fullUrl\":\"Organization\\/1\",\"resource\":{\"resourceType\":\"Organization\",\"id\":\"1\",\"meta\":{\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/Organization\"]},\"text\":{\"status\":\"generated\",\"div\":\"<divxmlns=\\\"http:\\/\\/www.w3.org\\/1999\\/xhtml\\\">XYZLabPvt.Ltd.ph:8905929811,email:<ahref=\\\"mailto:[email protected]\\\">[email protected]<\\/a><\\/div>\"},\"identifier\":[{\"type\":{\"coding\":[{\"system\":\"http:\\/\\/terminology.hl7.org\\/CodeSystem\\/v2-0203\",\"code\":\"PRN\",\"display\":\"Providernumber\"}]},\"system\":\"https:\\/\\/facility.ndhm.gov.in\\/\",\"value\":\"4567878\"}],\"name\":\"XYZLabPvt.Ltd.\",\"telecom\":[{\"system\":\"phone\",\"value\":\"8905929811\",\"use\":\"work\"},{\"system\":\"email\",\"value\":\"[email protected]\",\"use\":\"work\"}]}},{\"fullUrl\":\"DiagnosticReport/DRF2021-03-15-13163\",\"resource\":{\"resourceType\":\"DiagnosticReport\",\"id\":\"1\",\"meta\":{\"versionId\":\"1\",\"lastUpdated\":\"2021-01-20T04:51:59.1497479Z\",\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/DiagnosticReportImaging\"]},\"text\":{\"status\":\"generated\",\"div\":\"<divxmlns=\\\"http:\\/\\/www.w3.org\\/1999\\/xhtml\\\">\\t\\t\\t\\t\\t\\t<h3>DiagnosticReportforManjoorKapoorissued9-July202014:26<\\/h3>\\t\\t\\t\\t\\t\\t<pre>code:CTofhead-neckImagingStudy:HEADandNECKCTDICOMimagingstudyConclusion:CTbrains:largetumorsphenoid\\/clivus.<\\/pre>\\t\\t\\t\\t\\t\\t<p>XYZLabPvt.Ltd.,Incsigned:ManjoorKapoorRadiologist<\\/p>\\t\\t\\t\\t\\t<\\/div>\"},\"identifier\":[{\"system\":\"https:\\/\\/xyz.com\\/lab\\/reports\",\"value\":\"5234342\"}],\"basedOn\":[{\"reference\":\"ServiceRequest/DRF2021-03-15-13163\"}],\"status\":\"final\",\"category\":[{\"coding\":[{\"system\":\"http:\\/\\/snomed.info\\/sct\",\"code\":\"310128004\",\"display\":\"Computerizedtomographyservice\"}]}],\"code\":{\"coding\":[{\"system\":\"http:\\/\\/loinc.org\",\"code\":\"82692-5\",\"display\":\"CTHeadandNeckWOcontrast\"}],\"text\":\"CTHeadandNeckWOcontrast\"},\"subject\":{\"reference\":\"Patient/d08d5007-f6fd-48a6-9e47-52ffe4b95da6\",\"display\":\"ManjoorKapoor\"},\"issued\":\"2021-01-20T04:51:59.1497479Z\",\"performer\":[{\"reference\":\"Organization\\/1\",\"display\":\"XYZLabPvt.Ltd.\"}],\"resultsInterpreter\":[{\"reference\":\"Practitioner/ManjoorKapoor\",\"display\":\"ManjoorKapoor\"}],\"imagingStudy\":[{\"reference\":\"ImagingStudy\\/1\",\"display\":\"HEADandNECKCTDICOMimagingstudy\"}],\"media\":[{\"link\":{\"reference\":\"Media\\/1\"}}],\"conclusion\":\"CTbrains:largetumorsphenoid\\/clivus.\",\"conclusionCode\":[{\"coding\":[{\"system\":\"http:\\/\\/snomed.info\\/sct\",\"code\":\"188340000\",\"display\":\"Malignanttumorofcraniopharyngealduct\"}]}],\"presentedForm\":[{\"contentType\":\"application\\/pdf\",\"language\":\"en-IN\",\"data\":\"JVBERi0xLjcKCjQgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbmd0aCA4MzUKPj4Kc3RyZWFtCnicdVZLrhQxDNz3KWaN1FYcO79jsOIASMDiPSS4/wLHnyTNg1l5ynHFLjtJJ2glye+VIKWncX/0dUYYOSXm19f369eFH4KWsVyZGJrEJHwRF0goVprhN+Ly3Jky1CF2fr1fSNCq5XDgbwfeKjCp9fbgOfEf15dPr59X+n+Ov7//w/t+HTWUHlJgtmpgLHWoqUUwzHh9vQSttlAqLbFwFIeG+W6M2Bo7zFiEZn8aZI/NYTVoFFAb1gzV0mMJiBwlT5Cgd4dck5uB6xOasb0DmsT9UFVQFftA7z4gDxV6byNYC+xIaKRYulMXzCl3hQMhW+8eWghc6xijH6qNLBsI1g5xBctVsUcbBC6oO+2GCVZJlo6jrxtbTfdwh6UpvNc65+xB/Xv/qTefDJ6riD5w1dqS0RboaYE096qvu9oGS8BRbLGohUvByEFk5dUBLV2OUY851b6O3Tjg4VaH7tt1qH2BGKYdN2Mo+4Au/O0BI0mfu/CRzkwRZY0cEWX+NP/paIDF8p4O7R7pvjzL4QlLaUU7PhOn6vwCa5k5RNGKyDyZzB6T0mI1wDnnEEUbBR6sDfH25KgAvcVk44ABZzukBvcU9BRLlIds5rUuXsoKrH3QNOvO54TlBO1WPTxjTcmkd6nEbZOcNZ/hjcW8ZPa6VqZZ7F1ADfosBQybzDFLNBMzh+bOgzk8ZY3yHODmggqs49l9hF2FXCEZ7P2KHKYnhmNeDounQXJY+l7Y5RfYV+sgZpv2uUNBQCvgTR3sZ2M62BcJ7MdZ4ZgCMcsBu1S6AT4C4jwVmbfuiQonOg8PqDHOAtPm4b5O+/Sw8wicojKBy4Tn1SC186avs65iPCJj3QG12gSxzFje9LXpybtZrn8+4LEOjDzYdPJ4AO0Z03y8AdQf5XLW1fq+SKZt75CLZnpTfdSVsgVTAbWGqemfEcrDUFY+aM/RvDv5KBfXQJDcqXEepRXeRuWhg0de56iL5MrzjaVJDZ3+Cee8BuvwnDfceigfKK1Le1+ddNyccceKzmvdcR9PfQzed7cMZAksLnlclI8HIa3d9+ORYsHxysjIYuR2vEgiUor0/PXan3rrlfv4PSSxH8H5dfXt+nz9AUin8XsKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8Cj4+CmVuZG9iagozIDAgb2JqCjw8Ci9Db250ZW50cyBbIDQgMCBSIF0KL0Nyb3BCb3ggWyAwLjAgMC4wIDU5NS4zMjAwMSA4NDEuOTIwMDQgXQovTWVkaWFCb3ggWyAwLjAgMC4wIDU5NS4zMjAwMSA4NDEuOTIwMDQgXQovUGFyZW50IDIgMCBSCi9SZXNvdXJjZXMgNSAwIFIKL1JvdGF0ZSAwCi9UeXBlIC9QYWdlCj4+CmVuZG9iagoyIDAgb2JqCjw8Ci9Db3VudCAxCi9LaWRzIFsgMyAwIFIgXQovVHlwZSAvUGFnZXMKPj4KZW5kb2JqCjEgMCBvYmoKPDwKL1BhZ2VzIDIgMCBSCi9UeXBlIC9DYXRhbG9nCj4+CmVuZG9iago2IDAgb2JqCjw8Ci9BdXRob3IgKERyaWVmY2FzZSkKL0NyZWF0aW9uRGF0ZSAoRDoyMDE5MDQxNTE3MDcxMCswNSczMCcpCi9Nb2REYXRlIChEOjIwMTkwNDE1MTcwNzEwKzA1JzMwJykKL1Byb2R1Y2VyIChNaWNyb3NvZnQ6IFByaW50IFRvIFBERikKL1RpdGxlICgxLmRvYykKPj4KZW5kb2JqCnhyZWYKMCA3DQowMDAwMDAwMDAwIDY1NTM1IGYNCjAwMDAwMDExNzMgMDAwMDAgbg0KMDAwMDAwMTExNCAwMDAwMCBuDQowMDAwMDAwOTM3IDAwMDAwIG4NCjAwMDAwMDAwMDkgMDAwMDAgbg0KMDAwMDAwMDkxNiAwMDAwMCBuDQowMDAwMDAxMjIyIDAwMDAwIG4NCnRyYWlsZXIKPDwKL0luZm8gNiAwIFIKL1Jvb3QgMSAwIFIKL1NpemUgNwo+PgpzdGFydHhyZWYKMTM5MAolJUVPRgo=\",\"title\":\"DiagnosticReport\"}]}},{\"fullUrl\":\"DocumentReference/DRF2021-03-15-13163\",\"resource\":{\"resourceType\":\"DocumentReference\",\"id\":\"1\",\"meta\":{\"profile\":[\"https:\\/\\/nrces.in\\/ndhm\\/fhir\\/r4\\/StructureDefinition\\/DocumentReference\"]},\"text\":{\"status\":\"generated\",\"div\":\"<divxmlns=\\\"http:\\/\\/www.w3.org\\/1999\\/xhtml\\\"><p><b>GeneratedNarrative<\\/b><\\/p><p><b>id<\\/b>:1<\\/p><p><b>meta<\\/b>:<\\/p><p><b>status<\\/b>:current<\\/p><p><b>docStatus<\\/b>:final<\\/p><p><b>type<\\/b>:<spantitle=\\\"Codes:{http:\\/\\/snomed.info\\/sct4241000179101}\\\">Laboratoryreport<\\/span><\\/p><p><b>subject<\\/b>:<ahref=\\\"#Patient_1\\\">Seeabove(Patient/d08d5007-f6fd-48a6-9e47-52ffe4b95da6)<\\/a><\\/p><h3>Contents<\\/h3><tableclass=\\\"grid\\\"><tr><td>-<\\/td><td><b>Attachment<\\/b><\\/td><\\/tr><tr><td>*<\\/td><td><\\/td><\\/tr><\\/table><\\/div>\"},\"status\":\"current\",\"docStatus\":\"final\",\"type\":{\"coding\":[{\"system\":\"http:\\/\\/snomed.info\\/sct\",\"code\":\"4241000179101\",\"display\":\"Laboratoryreport\"}],\"text\":\"Laboratoryreport\"},\"subject\":{\"reference\":\"Patient/d08d5007-f6fd-48a6-9e47-52ffe4b95da6\"},\"content\":[{\"attachment\":{\"contentType\":\"application\\/pdf\",\"language\":\"en-IN\",\"data\":\"JVBERi0xLjcKCjQgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbmd0aCA4MzUKPj4Kc3RyZWFtCnicdVZLrhQxDNz3KWaN1FYcO79jsOIASMDiPSS4/wLHnyTNg1l5ynHFLjtJJ2glye+VIKWncX/0dUYYOSXm19f369eFH4KWsVyZGJrEJHwRF0goVprhN+Ly3Jky1CF2fr1fSNCq5XDgbwfeKjCp9fbgOfEf15dPr59X+n+Ov7//w/t+HTWUHlJgtmpgLHWoqUUwzHh9vQSttlAqLbFwFIeG+W6M2Bo7zFiEZn8aZI/NYTVoFFAb1gzV0mMJiBwlT5Cgd4dck5uB6xOasb0DmsT9UFVQFftA7z4gDxV6byNYC+xIaKRYulMXzCl3hQMhW+8eWghc6xijH6qNLBsI1g5xBctVsUcbBC6oO+2GCVZJlo6jrxtbTfdwh6UpvNc65+xB/Xv/qTefDJ6riD5w1dqS0RboaYE096qvu9oGS8BRbLGohUvByEFk5dUBLV2OUY851b6O3Tjg4VaH7tt1qH2BGKYdN2Mo+4Au/O0BI0mfu/CRzkwRZY0cEWX+NP/paIDF8p4O7R7pvjzL4QlLaUU7PhOn6vwCa5k5RNGKyDyZzB6T0mI1wDnnEEUbBR6sDfH25KgAvcVk44ABZzukBvcU9BRLlIds5rUuXsoKrH3QNOvO54TlBO1WPTxjTcmkd6nEbZOcNZ/hjcW8ZPa6VqZZ7F1ADfosBQybzDFLNBMzh+bOgzk8ZY3yHODmggqs49l9hF2FXCEZ7P2KHKYnhmNeDounQXJY+l7Y5RfYV+sgZpv2uUNBQCvgTR3sZ2M62BcJ7MdZ4ZgCMcsBu1S6AT4C4jwVmbfuiQonOg8PqDHOAtPm4b5O+/Sw8wicojKBy4Tn1SC186avs65iPCJj3QG12gSxzFje9LXpybtZrn8+4LEOjDzYdPJ4AO0Z03y8AdQf5XLW1fq+SKZt75CLZnpTfdSVsgVTAbWGqemfEcrDUFY+aM/RvDv5KBfXQJDcqXEepRXeRuWhg0de56iL5MrzjaVJDZ3+Cee8BuvwnDfceigfKK1Le1+ddNyccceKzmvdcR9PfQzed7cMZAksLnlclI8HIa3d9+ORYsHxysjIYuR2vEgiUor0/PXan3rrlfv4PSSxH8H5dfXt+nz9AUin8XsKZW5kc3RyZWFtCmVuZG9iago1IDAgb2JqCjw8Cj4+CmVuZG9iagozIDAgb2JqCjw8Ci9Db250ZW50cyBbIDQgMCBSIF0KL0Nyb3BCb3ggWyAwLjAgMC4wIDU5NS4zMjAwMSA4NDEuOTIwMDQgXQovTWVkaWFCb3ggWyAwLjAgMC4wIDU5NS4zMjAwMSA4NDEuOTIwMDQgXQovUGFyZW50IDIgMCBSCi9SZXNvdXJjZXMgNSAwIFIKL1JvdGF0ZSAwCi9UeXBlIC9QYWdlCj4+CmVuZG9iagoyIDAgb2JqCjw8Ci9Db3VudCAxCi9LaWRzIFsgMyAwIFIgXQovVHlwZSAvUGFnZXMKPj4KZW5kb2JqCjEgMCBvYmoKPDwKL1BhZ2VzIDIgMCBSCi9UeXBlIC9DYXRhbG9nCj4+CmVuZG9iago2IDAgb2JqCjw8Ci9BdXRob3IgKERyaWVmY2FzZSkKL0NyZWF0aW9uRGF0ZSAoRDoyMDE5MDQxNTE3MDcxMCswNSczMCcpCi9Nb2REYXRlIChEOjIwMTkwNDE1MTcwNzEwKzA1JzMwJykKL1Byb2R1Y2VyIChNaWNyb3NvZnQ6IFByaW50IFRvIFBERikKL1RpdGxlICgxLmRvYykKPj4KZW5kb2JqCnhyZWYKMCA3DQowMDAwMDAwMDAwIDY1NTM1IGYNCjAwMDAwMDExNzMgMDAwMDAgbg0KMDAwMDAwMTExNCAwMDAwMCBuDQowMDAwMDAwOTM3IDAwMDAwIG4NCjAwMDAwMDAwMDkgMDAwMDAgbg0KMDAwMDAwMDkxNiAwMDAwMCBuDQowMDAwMDAxMjIyIDAwMDAwIG4NCnRyYWlsZXIKPDwKL0luZm8gNiAwIFIKL1Jvb3QgMSAwIFIKL1NpemUgNwo+PgpzdGFydHhyZWYKMTM5MAolJUVPRgo=\",\"title\":\"Laboratoryreport\",\"creation\":\"2021-03-15T16:12:43.2682813Z\"}}]}}]}", "media": "application/fhir+json", "checksum": null, "careContextReference": "55c4573d-d9da-49c3-85f9-261c5c317b4d", "link": null } ], "keyMaterial": { "cryptoAlg": "ECDH", "curve": "Curve25519", "dhPublicKey": { "expiry": "2021-03-15T16:12:43.4077066Z", "parameters": null, "keyValue": "MIIBMTCB6gYHKoZIzj0CATCB3gIBATArBgcqhkjOPQEBAiB/////////////////////////////////////////7TBEBCAqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqYSRShRAQge0Je0Je0Je0Je0Je0Je0Je0Je0Je0Je0JgtenHcQyGQEQQQqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq0kWiCuGaG4oIa04B7dLHdI0UySPU1+bXxhsinpxaJ+ztPZAiAQAAAAAAAAAAAAAAAAAAAAFN753qL3nNZYEmMaXPXT7QIBCANCAAQ+Dp+eEaXGdpD8t5MR1iOH4qQiLduMCkBFSoKA38WpihtrcUyi36bsHBmRp5E0yb1H2COBJDc3gn4IBpj1BGaK" }, "nonce": "DLNDgPKrAr3XGthN4Bk9AMfzGfLlgeHjj+uJHZLSLSg=" } }

Add Support for GBK Encoding

Flutter received a request to officially support GBK encoding (flutter/flutter#45014), and it seemed more appropriate as a Dart request.

It seems that a decent percentage of Chinese websites run on GBK encoding (https://w3techs.com/technologies/segmentation/sl-cnter-/character_encoding). As far as I understand, GBK is an extension of GB2312, which appears on the chart.

According to our user, there are third-party packages like fast_gbk, but our user claims that bugs in those packages with some special characters are prevent their use in a release version of their app.

Would it be a huge effort to officially support GBK encoding in Dart?

cc/ @monkingame, who filed the request in flutter/flutter

dart fails to jsonDecode valid json string from typicode Posts with \n in it

Hi folks,
Dart fails to jsonDecode a valid json string which i copied from typicode Posts with \n in it.
please see

To see non error behaviour comment out lines 29 & 30.

I need to count on being able to decode good json.

Any help for a workaround would be appreciated.
Thanks.
Love and peace,
Joe Dorocak

base64 to pdf loss of information

When decoding a base64 through the website : https://www.base64decode.org
I can see the all info, including fields added by a legal partner (right column in table below).
When I display the same base64 within flutter_full_pdf_viewer, info is hidden.

Screenshot 2021-05-20 at 12 19 04

Screenshot 2021-05-20 at 12 20 21

It seems some information is lost in the decoding process, this is how the base64 is treated :

String normalized = base64.normalize(base64Raw);
Uint8List decodedBytes = base64Decode(normalized);
return await writeFile(decodedBytes);

Pdf is displayed within a FutureBuilder using :
PDFViewerScaffold(path: snapshot.data)

Thank you for this package and for any kind of support

Version issue when importing dart:convert

When I try and run a file in which I import dart:convert, I get the following error message:

../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/convert.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/accumulator_sink.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/byte_accumulator_sink.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/codepage.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/codepage.dart:167:18: Error: This requires the 'non-nullable' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.
CodePageEncoder? _encoder;
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/codepage.dart:216:38: Error: This requires the 'non-nullable' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.
Uint8List encode(String input, {int? invalidCharacter}) =>
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/codepage.dart:399:39: Error: This requires the 'non-nullable' experiment to be enabled.
Try enabling this experiment by adding it to the command line when compiling and running.
Uint8List convert(String input, {int? invalidCharacter}) {
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/hex.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/identity_codec.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
import 'dart:convert';
^
../../../../.pub-cache/hosted/pub.dartlang.org/convert-3.0.0-nullsafety.0/lib/src/percent.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.8.
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file

Running flutter doctor -v I get:

[✓] Flutter (Channel beta, 1.25.0-8.2.pre, on macOS 11.1 20C69 darwin-x64, locale en-CA)
• Flutter version 1.25.0-8.2.pre at /Users/calummurray/AndroidStudioProjects/flutter
• Framework revision b0a2299859 (13 days ago), 2021-01-05 12:34:13 -0800
• Engine revision 92ae191c17
• Dart version 2.12.0 (build 2.12.0-133.2.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/calummurray/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.9.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1

[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141

• No issues found!

How can I fix this?

Percent encode unexpectedly encodes numbers

I'm integrating with the twitter API which describes that data should be "percent encoded". In C# I found that the method that matched Twitters docs was Uri.EscapeDataString. I'm trying to do the same thing in Dart and discovered that none of them methods on the Uri class behaved correctly, but someone pointed me at this package.

This seems to work great for all the characters I've tried, except numbers:

// Dart:
print(percent.encode("1".codeUnits)); // outputs %31
// C#:
Console.WriteLine(Uri.EscapeDataString("1")); // outputs 1

The C# version seems to match twitter definition of "percent encoding" but I'm struggling to find detailed docs on whether this is a standard and if so, which is correct. I'm raising it here in the hope that either a) it's a bug and can be fixed or b) there's another method I want that behaves as C# does/twitter expects.

Traversing with level of traversed objects, without accumulation

What if I need traverse a json looking for specific objects based on <key, value, level of nesting>?
We have the reviver in JsonDecoder, but it does not provide the level of <key, value> and accumulate the resulting object (with useless memory consumption) that I won't need.

Inconsistent letter case between DateFormat and FixedDateTimeFormatter

FixedDateTimeFormatter is a remedy for broken DateFormat (dart-lang/i18n#211) therefore most often people will switch to it from DateFormat.

While DateFormat uses this approach:

/// The following characters are available in explicit patterns:
///
///     Symbol   Meaning                Presentation       Example
///     ------   -------                ------------       -------
///     G        era designator         (Text)             AD
///     y        year                   (Number)           1996
///     M        month in year          (Text & Number)    July & 07
///     L        standalone month       (Text & Number)    July & 07
///     d        day in month           (Number)           10
///     c        standalone day         (Number)           10
///     h        hour in am/pm (1~12)   (Number)           12
///     H        hour in day (0~23)     (Number)           0
///     m        minute in hour         (Number)           30
///     s        second in minute       (Number)           55
///     S        fractional second      (Number)           978
///     E        day of week            (Text)             Tuesday
///     D        day in year            (Number)           189
///     a        am/pm marker           (Text)             PM
///     k        hour in day (1~24)     (Number)           24
///     K        hour in am/pm (0~11)   (Number)           0
///     Q        quarter                (Text)             Q3

FixedDateTimeFormatter uses the other one.

/// The allowed characters are
/// * `Y`	for “calendar year”
/// * `M`	for “calendar month”
/// * `D`	for “calendar day”
/// * `E`	for “decade”
/// * `C`	for “century”
/// * `h`	for “clock hour”
/// * `m`	for “clock minute”
/// * `s`	for “clock second”
/// * `S`	for “fractional clock second”

I agree, that it's nice to make date-letters upper-case and time-letters lower-case (#66 (comment)), but because of the reason described at the beginning of this issue - I think that even more important is to follow "The least surprise rule" and both character casing should be consistent.

Returns the wrong type for utf8.encode

utf8.encode It should returns datatype of List<int> right? But actually it didn't, I noticed that Uint8List was returned instead List<int>.
This issue happens because the input encoded by encoder.convert and this returns Uint8List
I hope to fix it soon

Thank You

Can't decode a base64 string with newlines. Is this the intended behavior?

Base64Decoder cannot convert a base64 string that is split to blocks of a certain length by newlines, like:

PGEgaHJlZj0iaHR0cHM6Ly9mbHV0dGVyLmRldi8iPgogIDxoMSBhbGlnbj0i
Y2VudGVyIj4KICAgIDxwaWN0dXJlPgogICAgICA8c291cmNlIG1lZGlhPSIo
cHJlZmVycy1jb2xvci1zY2hlbWU6IGRhcmspIiBzcmNzZXQ9Imh0dHBzOi8v

Is this the intended behavior? The base64 command can decode it, but I don't know which behavior is the way it should be.

# This shell command works fine.
$ echo "PGEgaHJlZj0iaHR0cHM6Ly9mbHV0dGVyLmRldi8iPgogIDxoMSBhbGlnbj0i
Y2VudGVyIj4KICAgIDxwaWN0dXJlPgogICAgICA8c291cmNlIG1lZGlhPSIo
cHJlZmVycy1jb2xvci1zY2hlbWU6IGRhcmspIiBzcmNzZXQ9Imh0dHBzOi8v" | base64 --decode

<a href="https://flutter.dev/">
  <h1 align="center">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://%                                         

Background

I found this when trying to get the README of a GitHub repository using the REST API. It returns the README file as a base64 encoded string that is split into blocks of a certain length by newlines. I tried to convert this to a String, but always failed while decoding the baase64 string to Unit8List.

// Dart 3.0.5
// http: ^1.1.0

import 'dart:convert';

import 'package:http/http.dart' as http;

// GitHub API:
// https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-a-repository-readme
void main() async {
  const owner = "flutter";
  const repo = "flutter";
  final url = Uri.https(
    "api.github.com",
    "repos/$owner/$repo/readme",
  );
  final response = await http.get(
    url,
    headers: {
      "accept": "application/vnd.github+json",
    },
  );
  final json = jsonDecode(response.body);
  // This ↓ line causes "FormatException: Invalid character"
  final content = base64.decode(json["content"]);
  final readme = String.fromCharCodes(content);
  print(readme);
}

Then it throws:

Unhandled exception:
FormatException: Invalid character (at character 61)
PGEgaHJlZj0iaHR0cHM6Ly9mbHV0dGVyLmRldi8iPgogIDxoMSBhbGlnbj0i
                                                            ^

#0      _Base64Decoder.decodeChunk (dart:convert/base64.dart:705:7)
#1      _Base64Decoder.decode (dart:convert/base64.dart:629:14)
#2      Base64Decoder.convert (dart:convert/base64.dart:509:26)
#3      Base64Codec.decode (dart:convert/base64.dart:83:47)
<asynchronous suspension>

Removing the all newlines will fix this problem.

final content = base64.decode(json["content"].replaceAll("\n", ""));

You can see the returned json from the API as follows:

curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/flutter/flutter/readme

Unable to encode Arabic text using hexEncoder or Base64Encoder

Hello,
I'm and android developer and I have recently decided to move to dart/flutter,

I'm currently facing a problem where i cannot encode (Hex or base64) Arabic text
below is my sample code

-------------dart hexEncoder---------------------
HexEncoder hexEncoder = hex.encoder;
String utf8Data = 'شربل';
String hexData = hexEncoder.convert(utf8Data.codeUnits);
-------------dart hexEncoder---------------------

-------------dart runtime error---------------------
Testing started at 1:56 PM ...

package:convert/src/hex/encoder.dart 78:5 _convert
package:convert/src/hex/encoder.dart 22:38 HexEncoder.convert
test/security_encryption_test.dart 19:33 main.

FormatException: Invalid byte 0x634. (at offset 0)

flutter_doctor.log

Are JsonDecode() and JsonEncoder() has a try option?

This option work like int.tryParse() that will return int?.

Where are these?

  JsonDecoder().tryConvert(data);
  JsonEncoder().tryConvert(data);

I can create this by

class Json {
  static String? tryEncode(data) {
    try {
      return jsonEncode(data);
    } catch (e) {
      return null;
    }
  }

  static dynamic tryDecode(data) {
    try {
      return jsonDecode(data);
    } catch (e) {
      return null;
    }
  }
}

void main() {
  String? jsonEncode = Json.tryEncode(dataEncoded);
  dynamic jsonDecode = Json.tryDecode(dataDecoded);
  print("jsonEncode: $jsonEncode");
  print("jsonDecode: $jsonDecode");
}

However, I'm uncomfortable with this.
Is it impossible to add this function?

New issue with DART 3.2.0

if (password.length > 64) {
final passwordDigest = md5.convert(password);
password = Uint8List.fromList(passwordDigest.bytes);
}

../../../.pub-cache/hosted/pub.dev/enough_mail-2.1.4/lib/src/private/smtp/commands/smtp_auth_cram_md5_command.dart:50:33: Error: A value of type 'List' can't be assigned to a variable of type 'Uint8List'.

  • 'List' is from 'dart:core'.
  • 'Uint8List' is from 'dart:typed_data'.
    password = passwordDigest.bytes;

please add cp-850 and Windows1252 support

please add cp-850 and Windows1252 support

for decoding text in excel MS DOS CSV sheets

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);
}

Add support for UTF-16

The only way we had to decode UTF-16 previously was package:utf which has been discontinued. We should add a utf16 encoder and decoder here.

jsonarray decode gets error: flutter: FormatException

the json string like this :
[ { "A": "bbbb", "B": "11817" }, { "A": "bbbb", "B": "11817" } ]

when decode by convert,
` else if (json.startsWith("[")) {
//is jsonArray

  List decode = const JsonCodec().decode(json);

..............`
the error found:

flutter: FormatException: Unexpected character (at character 3)
[{A: bbbb, B: 11817}, {A: bbbb, B: 11817}]
^
json: [{A: bbbb, B: 11817}, {A: bbbb, B: 11817}]`

How to convert multiple formats?

I'm fetching the data from a csv file. The data consists of both ascii & utf-8 item in it. I'm trying to convert the particular data to List with the help of CsvToListConverter but before that I'm getting an error while transforming the code to a list when using

final input = new File(entities[i].path).openRead(); //How I'm reading the file
final fields = await input.transform(utf8.decoder).toList(); //How I'm trying to decode the data

This is how the data is

PO26106217000‡BO26106217010‡010‡M.G   Khamar B.O‡085368‡5000.00‡0.00
LEGACY_UPDATION‡Success-1
SANCTIONED_DELETION‡Success-1
SANCTIONED_INSERTION‡Success-1
UPDATE_WALLET‡Success-1
INSERTION_CLOSING_BAL‡Success-1
INSERTION_OPENING_BAL‡Success-1
INSERTION_OPENING_STOCK‡Success-1

Problem with percent.encode()

Hello, I have a problem with percent.encode().
I have an API that is used by the Arabs and can contain Arabic characters. One of the Arabic characters is "خ" and if I want to convert it with this method percent.encode('خ'.codeUnits). The code unit number is 1582 which represents 0x62e in hexadecimal. In this case, I will get an exception because it's out of range of the bytes that this library can convert. and I have this exception Unhandled Exception: FormatException: Invalid byte 0x62. Can you please help me with my problem? are there any alternatives I can use?

hex can't decode odd length strings

hex.decode("1")-> fail
hex.decode("01")-> ok

since toRadixString(16) converts 1 into "1" it makes a problem converting again to List with hex.decode

Solution:
-Count the String.length, if it's odd, do padLeft(srtLength+1,'0')

If this is implemented by default it will prevent bug from happening.

Flutter 2.5.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4cc385b4b8 (12 days ago) • 2021-09-07 23:01:49 -0700
Engine • revision f0826da7ef
Tools • Dart 2.14.0

jsonDecode() not getting UTF8 chars properly

Hey, so I'm getting fortnite usernames through an api. For example, instead of giving me COCA lightツ., it gives COCA lightã��.

If I hard code any of these special chars (flutter web), it works. And the raw response from the api gives me the good name.
Here's my method:

static dynamic getNameFromId(String id) async {
    final response = await http.get('https://fortniteapi.io/stats?account=$id', headers: {
      'Authorization': FortniteAPI.auth,
    });
    if (response.statusCode == 200) {
      return jsonDecode(response.body)['name'];
    } else {
      return null;
    }
  }

Fails to decode valid json

Json

{  "type": "MethodCallResult",  "value": {    "result": {      "type": "Null"    },    "success": {      "type": "Bool",      "value": false    },    "error": {      "type": "String",      "value": "java.lang.reflect.InvocationTargetException\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat com.jfixby.scarabei.red.reflect.JavaMethodCall.invoke(JavaMethodCall.java:22)\r\n\tat com.jfixby.scarabei.red.reflect.JavaCallExecutor.executeCall(JavaCallExecutor.java:11)\r\n\tat com.jfixby.scarabei.red.reflect.CrossLanguageCallAdaptor.processCrossLanguageMethodCall(CrossLanguageCallAdaptor.java:26)\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.main(TestMethodCall.java:27)\r\nCaused by: java.io.IOException: hello\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.test(TestMethodCall.java:34)\r\n\t... 8 more\r\n\r\njava.io.IOException: hello\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.test(TestMethodCall.java:34)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat com.jfixby.scarabei.red.reflect.JavaMethodCall.invoke(JavaMethodCall.java:22)\r\n\tat com.jfixby.scarabei.red.reflect.JavaCallExecutor.executeCall(JavaCallExecutor.java:11)\r\n\tat com.jfixby.scarabei.red.reflect.CrossLanguageCallAdaptor.processCrossLanguageMethodCall(CrossLanguageCallAdaptor.java:26)\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.main(TestMethodCall.java:27)\r\n"    }  }}

Same

{
  "type": "MethodCallResult",
  "value": {
    "result": {
      "type": "Null"
    },
    "success": {
      "type": "Bool",
      "value": false
    },
    "error": {
      "type": "String",
      "value": "java.lang.reflect.InvocationTargetException\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat com.jfixby.scarabei.red.reflect.JavaMethodCall.invoke(JavaMethodCall.java:22)\r\n\tat com.jfixby.scarabei.red.reflect.JavaCallExecutor.executeCall(JavaCallExecutor.java:11)\r\n\tat com.jfixby.scarabei.red.reflect.CrossLanguageCallAdaptor.processCrossLanguageMethodCall(CrossLanguageCallAdaptor.java:26)\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.main(TestMethodCall.java:27)\r\nCaused by: java.io.IOException: hello\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.test(TestMethodCall.java:34)\r\n\t... 8 more\r\n\r\njava.io.IOException: hello\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.test(TestMethodCall.java:34)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:498)\r\n\tat com.jfixby.scarabei.red.reflect.JavaMethodCall.invoke(JavaMethodCall.java:22)\r\n\tat com.jfixby.scarabei.red.reflect.JavaCallExecutor.executeCall(JavaCallExecutor.java:11)\r\n\tat com.jfixby.scarabei.red.reflect.CrossLanguageCallAdaptor.processCrossLanguageMethodCall(CrossLanguageCallAdaptor.java:26)\r\n\tat com.jfixby.scarabei.examples.reflect.TestMethodCall.main(TestMethodCall.java:27)\r\n"
    }
  }
}

Error

Unhandled exception:
FormatException: Control character in string (at character 243)
...type": "String",      "value": "java.lang.reflect.InvocationTargetException
                                                                              ^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1352)
#1      _ChunkedJsonParser.parseString (dart:convert-patch/convert_patch.dart:1025)
#2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:838)
#3      _parseJson (dart:convert-patch/convert_patch.dart:20)
#4      JsonDecoder.convert (dart:convert/json.dart:494)
#5      JsonCodec.decode (dart:convert/json.dart:125)

Get this error

'package:convert/src/percent/encoder.dart': malformed type: line 23 pos 13: cannot resolve class 'ChunkedConverter' from 'PercentEncoder'
    extends ChunkedConverter<List<int>, String, List<int>, String> {

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.