Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi i cant flutter esc pos print Kazakh Letters. #31

Open
TamirlanBir opened this issue Nov 15, 2023 · 7 comments
Open

Hi i cant flutter esc pos print Kazakh Letters. #31

TamirlanBir opened this issue Nov 15, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@TamirlanBir
Copy link

TamirlanBir commented Nov 15, 2023

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>
@pr0gramista
Copy link
Owner

Hi, thanks for reporting the issue.
What code page name did you try to encode with? And also is the issue with particular characters or with any?

@pr0gramista pr0gramista added the bug Something isn't working label Nov 20, 2023
@TamirlanBir
Copy link
Author

Hi, I use parts CP866 and cp1251, and the error in the frequency of Kazakh letters ('ә', 'ғ', 'қ', 'ң', 'ө', 'ұ', 'ү', 'һ', 'і')

@pr0gramista
Copy link
Owner

Ah, I see. There is a Kazakh variant of CP1251, where those letters appear. Could you try to use KZ-1048 or its aliases STRK1048-2002, RK1048?

@TamirlanBir
Copy link
Author

Ah, I see. There is a Kazakh variant of CP1251, where those letters appear. Could you try to use KZ-1048 or its aliases STRK1048-2002, RK1048?

Doesn't work( There is the list of codePages , and there only RK1048

@TamirlanBir
Copy link
Author

@pr0gramista
hello! any news?

@pr0gramista
Copy link
Owner

Hi, I am afraid I have none.

The package itself isn't providing any code pages, instead it is handled by calls to underlying libraries, which I have no control of.

Perhaps you can write a necessary code page yourself. Not sure how Kazakh language is represented, but it might be as simple as mapping bytes from a table of codes.

@pr0gramista
Copy link
Owner

As an example, perhaps something like this would be enough:

// https://www.iana.org/assignments/charset-reg/KZ-1048

var map = {
  0x0000: 0x00,
  0x0001: 0x01,
  0x0002: 0x02,
  0x0003: 0x03,
  0x0004: 0x04,
  0x0005: 0x05,
  0x0006: 0x06,
  0x0007: 0x07,
  0x0008: 0x08,
  0x0009: 0x09,
  0x000A: 0x0a,
  0x000B: 0x0b,
  0x000C: 0x0c,
  0x000D: 0x0d,
  0x000E: 0x0e,
  0x000F: 0x0f,
  0x0010: 0x10,
  0x0011: 0x11,
  0x0012: 0x12,
  0x0013: 0x13,
  0x0014: 0x14,
  0x0015: 0x15,
  0x0016: 0x16,
  0x0017: 0x17,
  0x0018: 0x18,
  0x0019: 0x19,
  0x001A: 0x1a,
  0x001B: 0x1b,
  0x001C: 0x1c,
  0x001D: 0x1d,
  0x001E: 0x1e,
  0x001F: 0x1f,
  0x0020: 0x20,
  0x0021: 0x21,
  0x0022: 0x22,
  0x0023: 0x23,
  0x0024: 0x24,
  0x0025: 0x25,
  0x0026: 0x26,
  0x0027: 0x27,
  0x0028: 0x28,
  0x0029: 0x29,
  0x002A: 0x2a,
  0x002B: 0x2b,
  0x002C: 0x2c,
  0x002D: 0x2d,
  0x002E: 0x2e,
  0x002F: 0x2f,
  0x0030: 0x30,
  0x0031: 0x31,
  0x0032: 0x32,
  0x0033: 0x33,
  0x0034: 0x34,
  0x0035: 0x35,
  0x0036: 0x36,
  0x0037: 0x37,
  0x0038: 0x38,
  0x0039: 0x39,
  0x003A: 0x3a,
  0x003B: 0x3b,
  0x003C: 0x3c,
  0x003D: 0x3d,
  0x003E: 0x3e,
  0x003F: 0x3f,
  0x0040: 0x40,
  0x0041: 0x41,
  0x0042: 0x42,
  0x0043: 0x43,
  0x0044: 0x44,
  0x0045: 0x45,
  0x0046: 0x46,
  0x0047: 0x47,
  0x0048: 0x48,
  0x0049: 0x49,
  0x004A: 0x4a,
  0x004B: 0x4b,
  0x004C: 0x4c,
  0x004D: 0x4d,
  0x004E: 0x4e,
  0x004F: 0x4f,
  0x0050: 0x50,
  0x0051: 0x51,
  0x0052: 0x52,
  0x0053: 0x53,
  0x0054: 0x54,
  0x0055: 0x55,
  0x0056: 0x56,
  0x0057: 0x57,
  0x0058: 0x58,
  0x0059: 0x59,
  0x005A: 0x5a,
  0x005B: 0x5b,
  0x005C: 0x5c,
  0x005D: 0x5d,
  0x005E: 0x5e,
  0x005F: 0x5f,
  0x0060: 0x60,
  0x0061: 0x61,
  0x0062: 0x62,
  0x0063: 0x63,
  0x0064: 0x64,
  0x0065: 0x65,
  0x0066: 0x66,
  0x0067: 0x67,
  0x0068: 0x68,
  0x0069: 0x69,
  0x006A: 0x6a,
  0x006B: 0x6b,
  0x006C: 0x6c,
  0x006D: 0x6d,
  0x006E: 0x6e,
  0x006F: 0x6f,
  0x0070: 0x70,
  0x0071: 0x71,
  0x0072: 0x72,
  0x0073: 0x73,
  0x0074: 0x74,
  0x0075: 0x75,
  0x0076: 0x76,
  0x0077: 0x77,
  0x0078: 0x78,
  0x0079: 0x79,
  0x007A: 0x7a,
  0x007B: 0x7b,
  0x007C: 0x7c,
  0x007D: 0x7d,
  0x007E: 0x7e,
  0x007F: 0x7f,
  0x0402: 0x80,
  0x0403: 0x81,
  0x201A: 0x82,
  0x0453: 0x83,
  0x201E: 0x84,
  0x2026: 0x85,
  0x2020: 0x86,
  0x2021: 0x87,
  0x20AC: 0x88,
  0x2030: 0x89,
  0x0409: 0x8a,
  0x2039: 0x8b,
  0x040A: 0x8c,
  0x049A: 0x8d,
  0x04BA: 0x8e,
  0x040F: 0x8f,
  0x0452: 0x90,
  0x2018: 0x91,
  0x2019: 0x92,
  0x201C: 0x93,
  0x201D: 0x94,
  0x2022: 0x95,
  0x2013: 0x96,
  0x2014: 0x97,
  0x2122: 0x99,
  0x0459: 0x9a,
  0x203A: 0x9b,
  0x045A: 0x9c,
  0x049B: 0x9d,
  0x04BB: 0x9e,
  0x045F: 0x9f,
  0x00A0: 0xa0,
  0x04B0: 0xa1,
  0x04B1: 0xa2,
  0x04D8: 0xa3,
  0x00A4: 0xa4,
  0x04E8: 0xa5,
  0x00A6: 0xa6,
  0x00A7: 0xa7,
  0x0401: 0xa8,
  0x00A9: 0xa9,
  0x0492: 0xaa,
  0x00AB: 0xab,
  0x00AC: 0xac,
  0x00AD: 0xad,
  0x00AE: 0xae,
  0x04AE: 0xaf,
  0x00B0: 0xb0,
  0x00B1: 0xb1,
  0x0406: 0xb2,
  0x0456: 0xb3,
  0x04E9: 0xb4,
  0x00B5: 0xb5,
  0x00B6: 0xb6,
  0x00B7: 0xb7,
  0x0451: 0xb8,
  0x2116: 0xb9,
  0x0493: 0xba,
  0x00BB: 0xbb,
  0x04D9: 0xbc,
  0x04A2: 0xbd,
  0x04A3: 0xbe,
  0x04AF: 0xbf,
  0x0410: 0xc0,
  0x0411: 0xc1,
  0x0412: 0xc2,
  0x0413: 0xc3,
  0x0414: 0xc4,
  0x0415: 0xc5,
  0x0416: 0xc6,
  0x0417: 0xc7,
  0x0418: 0xc8,
  0x0419: 0xc9,
  0x041A: 0xca,
  0x041B: 0xcb,
  0x041C: 0xcc,
  0x041D: 0xcd,
  0x041E: 0xce,
  0x041F: 0xcf,
  0x0420: 0xd0,
  0x0421: 0xd1,
  0x0422: 0xd2,
  0x0423: 0xd3,
  0x0424: 0xd4,
  0x0425: 0xd5,
  0x0426: 0xd6,
  0x0427: 0xd7,
  0x0428: 0xd8,
  0x0429: 0xd9,
  0x042A: 0xda,
  0x042B: 0xdb,
  0x042C: 0xdc,
  0x042D: 0xdd,
  0x042E: 0xde,
  0x042F: 0xdf,
  0x0430: 0xe0,
  0x0431: 0xe1,
  0x0432: 0xe2,
  0x0433: 0xe3,
  0x0434: 0xe4,
  0x0435: 0xe5,
  0x0436: 0xe6,
  0x0437: 0xe7,
  0x0438: 0xe8,
  0x0439: 0xe9,
  0x043A: 0xea,
  0x043B: 0xeb,
  0x043C: 0xec,
  0x043D: 0xed,
  0x043E: 0xee,
  0x043F: 0xef,
  0x0440: 0xf0,
  0x0441: 0xf1,
  0x0442: 0xf2,
  0x0443: 0xf3,
  0x0444: 0xf4,
  0x0445: 0xf5,
  0x0446: 0xf6,
  0x0447: 0xf7,
  0x0448: 0xf8,
  0x0449: 0xf9,
  0x044A: 0xfa,
  0x044B: 0xfb,
  0x044C: 0xfc,
  0x044D: 0xfd,
  0x044E: 0xfe,
  0x044F: 0xff,
};

void main() {
  print('сәлем, қалыңыз қалай?'
      .codeUnits
      .map((codeUnit) => map[codeUnit])
      .join(", "));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants