How to generate UTF-8 encoded SVG files from CLI

0 votes
asked May 16, 2023 in Question / help by Fred
Hi everyone,

I am currently in the midst of implementing a script to generate SVGs for all plantUML files in our repository. As plantUML is new to the company we started using the VSCode extension to generate diagrams at first.

As it turns out if I generate a SVG file with the VSCode extension I get an UTF-8 encoded SVG file with line breaks. In case of using the CLI from within my python script I get an US-ASCII encoded file without line breaks.

In addition the source comment which includes the plantUML file is in human readable form when generated via VSCode and in flat encoded form when generated via CLI.

Is there a way in which I can get the same output from both methods? We are currently considering adding the SVG files to version control so we have a complete documentation within git which can be read by project managers. Would be nice if the files stay the same if generated for a second time with another method.

Help is highly appreciated.

Thanks!

1 Answer

0 votes
answered May 16, 2023 by plantuml (294,960 points)
Sorry, we have recently changed SVG export to US-ASCII, because UTF-8 was an issue in some situations.

Could you check which PlantUML version are you using in both cases?

You can use:

@startuml
version
@enduml

for that.

Thanks!
commented May 16, 2023 by Fred
That would explain a lot.

VSCode ist using v1.2022.7

CLI is v1.2023.6

So US-ASCII will be the default format from now on. Including no line feeds within the SVG and flat encoded diagrams in the comment?

Thanks!
commented May 16, 2023 by plantuml (294,960 points)

So US-ASCII will be the default format from now on. Including no line feeds within the SVG and flat encoded diagrams in the comment?

Yes, exactly. This export is more safe.

Upgrading PlantUML version in VSCode should solve your issue. However, I don't know how to do that.

Hope this helps!

commented May 16, 2023 by Fred
Thanks a lot!

The VSCode extension can use a external binary instead of the built in. So if we use that we should be ok.
...