0

I have Turkish Character problem with c#. I am using Palmx (Zijang) ZJ8330 Thermal Printer. Can anyone help me?

My code :

        string tempFile = "C:\\deneme.txt";
        string PrinterName = "POS-80";
        StreamReader SR = new StreamReader(tempFile, Encoding.Default);
        string all = SR.ReadToEnd();
        SR.Close();

        all += newLine;
        all += "  Ürün                    Adet      Tutar";

  
        all += newLine + " ";
        all += newLine + " ";
        all += ESC + "E";
        all += newLine + " ";
        all += newLine + " ";
        all += newLine + " Mali Değeri Yoktur";
        all += newLine + " ";

        all += newLine + " Teşekkur ederiz ";
        all += newLine + " ";


        all += ESC + "@";
        all += GS + "V" + (char)1; // Cut receipt

        RawPrinterHelper.SendStringToPrinter(PrinterName, all);

And it is the function : (I am using RawPrinterHelper)

    public static bool SendStringToPrinter(string szPrinterName, string szString)
    {
        IntPtr pBytes;
        Int32 dwCount;
        // How many characters are in the string?
        dwCount = szString.Length;
        // Assume that the printer is expecting ANSI text, and then convert
        // the string to ANSI text.
        pBytes = Marshal.StringToCoTaskMemAnsi(szString);
        // Send the converted ANSI string to the printer.
        SendBytesToPrinter(szPrinterName, pBytes, dwCount);
        Marshal.FreeCoTaskMem(pBytes);
        return true;
    }
  • This is a font encoding problem, see duplicate. https://stackoverflow.com/questions/592824/c-sharp-help-reading-foreign-characters-using-streamreader – GGAnderson Jul 12 '20 at 19:50
  • 1
    Does this answer your question? [C# Help reading foreign characters using StreamReader](https://stackoverflow.com/questions/592824/c-sharp-help-reading-foreign-characters-using-streamreader) – GGAnderson Jul 12 '20 at 19:51
  • These are not working :( – Nkbasturk Jul 12 '20 at 20:08
  • I guess pBytes = Marshal.StringToCoTaskMemAnsi(szString); is has a problem. But when i write pBytes = Marshal.StringToCoTaskMemUni(szString); printer doesn't work – Nkbasturk Jul 12 '20 at 20:29
  • I solved my problem. But file created other someone's pc (I opened deneme txt via notepad++ and set encoding and save) after that i can edit and it works. But if i want to create the file via my pc it didn't work.I guess it depends on some settings in my pc. :Ç – Nkbasturk Jul 22 '20 at 10:29

0 Answers0