react-native-esc-pos-printer icon indicating copy to clipboard operation
react-native-esc-pos-printer copied to clipboard

Setting language to Japanese prints strange characters

Open TwenLeMammouth opened this issue 2 years ago • 8 comments

Hi, we are trying to print receipt in Japanese, but we only get some katakana and some shapes that shouldn't be here. await EscPosPrinter.init({ target: printer.target, seriesName: getPrinterSeriesByName(printer.name), language: 'EPOS2_LANG_JA', }) Using language: 'EPOS2_LANG_MULTI', didn't work either. ( I thought I needed that to print japanese and english characters..) Printing Japanese character works very well with the Epson app.

Screen Shot 2022-04-20 at 12 08 38

TwenLeMammouth avatar Apr 20 '22 03:04 TwenLeMammouth

Hello? Unfortunately I don’t have access to printer device now so I can’t test and fix it.

Have you tried to print another language ? Let’s say Chinese?

As a workaround you can use .data printing method and encode text manually with Japanese codepage. You can encode using https://www.npmjs.com/package/esc-pos-encoder#codepage this lib.

I.e.

let result = encoder .codepage('windows1251') .text('Iñtërnâtiônàlizætiøn') .codepage('cp936') .text('简体中文') .encode()

printing

// your printing commands .data(result) // your printing commands

.sendData()

Hope this helps

tr3v3r avatar Apr 20 '22 17:04 tr3v3r

@TwenLeMammouth have you resolved the issue?

tr3v3r avatar Apr 26 '22 22:04 tr3v3r

Yes, this is resolved, but not with the encoder.. There is some hardcoded english 'EPOS2_LANG_ANK', but I can't remember where, which sets the language to English. So changing the printer language doesn't work when you use 'EscPosPrinter.init()'.

But I now have another problem, I had to plug a second printer, and with '.discover()' it can find both, but one by one, I never get an array with both printers in it.. I tried to connect them both in ethernet, and both bluetooth, and also one Ethernet and one bluetooth.

TwenLeMammouth avatar Apr 26 '22 23:04 TwenLeMammouth

@TwenLeMammouth you are talking about iOS and discovery?

tr3v3r avatar Apr 27 '22 08:04 tr3v3r

I'm talking about this: const printers = await EscPosPrinter.discover() And yes, running on iOS.

TwenLeMammouth avatar Apr 27 '22 08:04 TwenLeMammouth

we have a bug for iOS

Could you please try to discover with this code?

import {
  NativeModules,
  NativeEventEmitter,
} from 'react-native';

const { EscPosPrinter, EscPosPrinterDiscovery } = NativeModules;

const discoveryEventEmmiter = new NativeEventEmitter(EscPosPrinterDiscovery);

discoveryEventEmmiter.addListener(
          'onDiscoveryDone',
          (printers) => {
            console.log(printers) 
          }
        );

EscPosPrinterDiscovery.discover(params)

tr3v3r avatar Apr 27 '22 10:04 tr3v3r

I can see every printers with this, thank you ! But I have a stupid question.. What needs to be pass as params in the last line...?

TwenLeMammouth avatar Apr 28 '22 01:04 TwenLeMammouth

@TwenLeMammouth you can skip it. It's optional. But if you're interested you can read here https://github.com/tr3v3r/react-native-esc-pos-printer/blob/main/docs/API.md#discoverparams

tr3v3r avatar Apr 28 '22 08:04 tr3v3r

we have a bug for iOS

Could you please try to discover with this code?

import {
  NativeModules,
  NativeEventEmitter,
} from 'react-native';

const { EscPosPrinter, EscPosPrinterDiscovery } = NativeModules;

const discoveryEventEmmiter = new NativeEventEmitter(EscPosPrinterDiscovery);

discoveryEventEmmiter.addListener(
          'onDiscoveryDone',
          (printers) => {
            console.log(printers) 
          }
        );

EscPosPrinterDiscovery.discover(params)

@tr3v3r I am using Expo Development Client for React Native. I tried to access these { EscPosPrinter, EscPosPrinterDiscovery } from

const { EscPosPrinter, EscPosPrinterDiscovery } = NativeModules;

but I could not. How can i do this as I am not using Xcode for ios.

Rehankhalil462 avatar Feb 14 '23 12:02 Rehankhalil462

fixed in v.3.0.0

https://github.com/tr3v3r/react-native-esc-pos-printer/releases/tag/vv3.0.0

tr3v3r avatar Nov 12 '23 15:11 tr3v3r

@TwenLeMammouth May i please ask how did you resolve the language issue? As i am facing the same situation. Could only print english properly, failed with EPOS2_LANG_JA, EPOS2_LANG_ZH_CN, EPOS2_LANG_ZH_TW a9294f772cd6a97cdd2e71807a75db89

doufu060514 avatar Feb 16 '24 10:02 doufu060514

As I said in a message before, there was some hardcoded english settings, in some shady files(for me) in the library, writen in a language I don't know. Maybe you can try to search all the files for this parameter "EPOS2_LANG_ANK". I'm sorry I don't think I can help more, it was 2 years ago, I don't have access to a printer anymore.

In the end, this issue shouldn't be closed if it was fixed only on my side and not on the library..

TwenLeMammouth avatar Feb 19 '24 13:02 TwenLeMammouth