]> granicus.if.org Git - graphviz/commit
explicitly specify latin-1 encoding when dealing with PS files in tests
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 6 Dec 2021 04:18:31 +0000 (20:18 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 14 Dec 2021 01:17:49 +0000 (17:17 -0800)
commit4ea0424037fc2eb6f15981ef38469694799d4b8d
tree3faa6e716a1c778cad1869d249f764c81d3fa619
parent40aed3a86b2f3ba1bab17caf67f10540b3748ca6
explicitly specify latin-1 encoding when dealing with PS files in tests

PostScript files are encoded in a character set called CCSID 1276.¹ This code
was working despite not specifying an encoding because the default encoding on
each platform coincidentally lines up with that used in their sample files. More
recent versions of Pylint warn that encoding should always be specified in
`open` calls, and attempting to use either ASCII or UTF-8 encoding fails. The
Linux sample files contain invalid ASCII bytes and the Windows sample files
contain invalid UTF-8 bytes. Using latin-1, which seems to be the closest
available encoding to CCSID 1276, works cross platform.

In future, this code should perhaps be adapted to do I/O in binary mode, thus
avoiding any encoding concerns.

¹ https://en.wikipedia.org/wiki/PostScript_Standard_Encoding
rtest/rtest.py