gofpdf icon indicating copy to clipboard operation
gofpdf copied to clipboard

Multiple Code Pages Possible?

Open scisci opened this issue 6 years ago • 5 comments

Hi, I know UTF-8 is not supported, but I'm wondering if its possible to automatically support multiple code pages. For instance, I have my fonts using the cp1252.map mapping, but if I get russian characters they just get translate to periods. Would it be possible to also somehow include the russian mapping and switch between the mappings on the fly?

scisci avatar Sep 06 '17 17:09 scisci

The ExampleFpdf_CellFormat_codepage() example shows how multiple code pages can be included in one document.

jung-kurt avatar Sep 07 '17 00:09 jung-kurt

Thanks, that helps. I can see the spot where it subs in a '.' character if it is not in the map.

https://github.com/jung-kurt/gofpdf/blob/cc7f4a2880e224dc55d15289863817df6d9f6893/util.go#L171

I guess I could make my own mapping function, so if the utf-8 code isn't found in the map, then it moves on to the next code page.

scisci avatar Sep 07 '17 01:09 scisci

I guess I could make my own mapping function, so if the utf-8 code isn't found in the map, then it moves on to the next code page.

Super idea! Multiple code pages could be loaded either in sequence or in a single function using variadic arguments. During text output, a generalized translator would search the maps in order for the right code page. This would be a very useful enhancement to this library.

jung-kurt avatar Sep 07 '17 01:09 jung-kurt

@scisci did you managed to solve this?

bronislav avatar Feb 13 '18 21:02 bronislav

Unfortunately not.

scisci avatar Feb 14 '18 02:02 scisci