diagrams / SVGFonts

Fonts from the SVG-Font format
http://hackage.haskell.org/package/SVGFonts
Other
20 stars 12 forks source link

invalid argument (invalid byte sequence) #30

Closed GregorySchwartz closed 5 years ago

GregorySchwartz commented 5 years ago

I'm getting the error hGetContents: invalid argument (invalid byte sequence) when SVGFonts attempts to read LinLibertine.svg inside of a docker container. Any ideas on how to fix this for docker or is it a locale issue?

byorgey commented 5 years ago

Hi @GregorySchwartz , unfortunately it looks like LinLibertine.svg contains a comment on line 7408,

<!--
Möglicherweise eher so wie in der Times?
-->

which contains a single non-ASCII character ö. (This is the only non-ASCII character in the entire file.) This character is in fact encoded using UTF-8, so you need to make sure your encoding is set to UTF-8 when reading the file. If I'm remembering correctly, the encoding gets picked up automatically from the locale setting if you just use hGetContents (which probably explains why it works for you locally but not inside a docker container---the locale settings are different inside the container), but I think (?) you should be able to set the encoding manually. I forget the details of how to do this though.

GregorySchwartz commented 5 years ago

Yes, I fixed it in docker with:

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

and installing locales. I also needed to copy the install folder containing LinLibertine.svg to a build folder in the docker filesystem containing the executable. I assume there is no easier solution?

byorgey commented 5 years ago

Well, if you're copying LinLibertine.svg anyway, I suppose you could also simply delete lines 7407-7409.

byorgey commented 5 years ago

This is also easy enough to fix upstream, in a minute I'll upload a point release of SVGFonts that removes the non-ASCII character.

byorgey commented 5 years ago

Uploaded SVGFonts-1.7.0.1.