CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2013
    Posts
    3

    Printing Chinese/unicode characters to a Line Printer using the WritePrinter method.

    I'm trying to print Chinese/unicode characters to a line printer(EPSON LQ-2090) using the writePrinter method in c++.
    ANSI characters print fine, but when I throw the buffer of widechar Chinese characters at it, they come out like garbage/ANSI chars.
    while debuging string shows chinese characters but in memory it shows ANSI characters not chinese and these ANSI characters are get printed on printer.
    Note that if I change the DocInfo datatype parameter to "TEXT" instead of "RAW" then also the Chinese characters donot print.
    Is there a way to get Chinese or unicode characters to print correctly?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Printing Chinese/unicode characters to a Line Printer using the WritePrinter meth

    How does "the writePrinter method in c++" know that data in the buffer represents Chinese/unicode characters rather than some ANSI text?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2013
    Posts
    3

    Re: Printing Chinese/unicode characters to a Line Printer using the WritePrinter meth

    Hi victor,
    thank you for reply.
    frankly i dont know "how writePrinter method in c++" know that data in the buffer are chinese rather than some ansi text.
    if you see the signature of writePrinter method
    BOOL WritePrinter(
    _In_ HANDLE hPrinter,
    _In_ LPVOID pBuf,
    _In_ DWORD cbBuf,
    _Out_ LPDWORD pcWritten
    );
    it takes buffer of type LPVOID as data for printing.it dosen't matter what is the type of buffer char * or wchar_t *.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Printing Chinese/unicode characters to a Line Printer using the WritePrinter meth

    Then do NOT use WritePrinter if you cannot tell it that buffer contains UNICODE characters!
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2013
    Posts
    3

    Re: Printing Chinese/unicode characters to a Line Printer using the WritePrinter meth

    Quote Originally Posted by VictorN View Post
    Then do NOT use WritePrinter if you cannot tell it that buffer contains UNICODE characters!
    Hi victor , Is there any Alternative to writePrinter API?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Printing Chinese/unicode characters to a Line Printer using the WritePrinter meth

    You could draw any text directly to the printer device context. Search MSDN for example...
    Victor Nijegorodov

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Printing Chinese/unicode characters to a Line Printer using the WritePrinter meth

    WritePrinter is a raw binary interface.
    It doesn't know about "ansi" or "unicode" or any other encoding format. you're simply sending a stream of bytes through this API directly to the printer.

    it's intended for direct access to the printer hardware and thus expects that you know how the hardware works.
    This printer may not support unicode at all (expecting GDI drawing of glyphs)
    If this printer does support unicode through this interface, it may require that you first send the approprate commands to switch the printer into unicode mode. (this is going to be hardware dependant, so look in your printer manual).

    Typically speaking, other than elementary text output, and specialty commands (such as commands to open the cash register on POS terminals, or to output text on a POS display) you should avoid this API and rather use regular drawing to output to the printer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured