Menu

#28 UTF-8 bug with newline \n char

open
nobody
None
9
2012-02-15
2012-02-15
Beny Boariu
No

I'm building a pdf with libharu, with UTF-8 encoding.

HPDF_UseUTFEncodings(pdf);

NSString *path = [[NSBundle mainBundle] pathForResource: @"DejaVuSans" ofType: @"ttf"];
const char *fontname = HPDF_LoadTTFontFromFile(pdf, [path UTF8String], HPDF_TRUE);

HPDF_Font fontEnUTF = HPDF_GetFont(pdf, fontname, "UTF-8");
HPDF_Page_SetFontAndSize(page3, fontEnUTF, 10.0);

const char* cString = [[itemsArray objectAtIndex:i] cStringUsingEncoding:NSUTF8StringEncoding];

HPDF_UINT charCount = 0;
HPDF_Page_TextRect(page3, 50.0, K_PORTRAIT_HEIGHT, HPDF_Page_GetWidth(page3)-52, 52.0, cString, HPDF_TALIGN_LEFT, &charCount);

Everything is fine, except that it wrongly encode \n char. See here output attached.

Discussion

  • Beny Boariu

    Beny Boariu - 2012-02-15

    Output UTF-8 encoding

     
  • Beny Boariu

    Beny Boariu - 2012-02-15
    • priority: 5 --> 9
     

Log in to post a comment.

MongoDB Logo MongoDB