Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign letters gets converted to ? #83

Closed
Agazoth opened this issue Dec 7, 2018 · 5 comments
Closed

Foreign letters gets converted to ? #83

Agazoth opened this issue Dec 7, 2018 · 5 comments

Comments

@Agazoth
Copy link

Agazoth commented Dec 7, 2018

When running Export-PSGraph on foreign letters they get converted to ?. Here is a test on the french ç and the danish ø:

graph g { edge "François" "Sørensen" } | Export-PSGraph -ShowGraph

Everything is fine in the Powershell code.

graph g { edge "François" "Sørensen" }
digraph g {
    compound="true";
    "François"->"Sørensen"
}

It is the creation of the image with dot.exe that introduces the error.
Line 187 in Export-PSGraph.ps1:

$standardInput.ToString() | & $graphViz

This issue should probably be stated to the team creating graphViz.

@KevinMarquette
Copy link
Owner

KevinMarquette commented Dec 8, 2018

I did a little more testing on this. When I pipe in your sample graph, I get this output:

digraph g {
    graph [bb="0,0,87.092,108",
            compound=true
    ];
    node [label="\N"];
    "Fran?ois"       [height=0.5,
            pos="43.546,90",
            width=1.1735];
    "S?rensen"       [height=0.5,
            pos="43.546,18",
            width=1.2096];
    "Fran?ois" -> "S?rensen"         [pos="e,43.546,36.104 43.546,71.697 43.546,63.983 43.546,54.712 43.546,46.112"];
}

This confirms what you are seeing. My next test was to save our graph as a file and give that as a parameter to $graphviz

& $graphviz c:\temp\graph.dot

digraph g {
    graph [bb="0,0,88.392,108",
            compound=true
    ];
    node [label="\N"];
    Franτois         [height=0.5,
            pos="44.196,90",
            width=1.1735];
    S°rensen         [height=0.5,
            pos="44.196,18",
            width=1.2277];
    Franτois -> S°rensen     [pos="e,44.196,36.104 44.196,71.697 44.196,63.983 44.196,54.712 44.196,46.112"];
}

I don't get the ? this time, but these characters are still not correct.

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.16299.666
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.666
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

@KevinMarquette
Copy link
Owner

I started trying to reproduce these results with PowerShell 6.1. From the console, this output also looks wrong:

$graph | & $graphViz
digraph g {
        graph [bb="0,0,88.392,108",
                compound=true
        ];
        node [label="\N"];
        François        [height=0.5,
                pos="44.196,90",
                width=1.1735];
        S├╕rensen        [height=0.5,
                pos="44.196,18",
                width=1.2277];
        François -> Sørensen   [pos="e,44.196,36.104 44.196,71.697 44.196,63.983 44.196,54.712 44.196,46.112"];
}

But if I actually generate a graph it will show the correct characters. It looks like this is solved in PowerShell 6.1. So this is a bug with Windows Powershell and the way it pipes to executables.

Still trying to chase down why saving to a file first is not working like I would expect. So I am playing with file encodings.

@KevinMarquette
Copy link
Owner

I was able to get it to work from a file if I saved it this way:

$graph  | Set-Content c:\temp\graph.dot -Encoding utf8NoBOM

But that encoding option is not available on Windows PowerShell 5.1

I hate to close the issue this way but I don't have an easy way to fix this on my end. It's resolved by updating PowerShell to the current version (PS 6.1).

@Agazoth
Copy link
Author

Agazoth commented Dec 8, 2018

The digraph I get when running the initail command is a lot different from yours.

I installed PSGraph in Powershell 6.1 - had to AllowClubber since node has a twin in PSDesiredStateConfiguration. In both Windows Powershell 5.1 and Powershell 6.1 I get this result:

PS C:\>graph g { edge "François" "Sørensen" }
digraph g {
    compound="true";
    "François"->"Sørensen"
}

No hight, position and width at all.

But in Powershell 6.1 there is a huge difference in the output. If I go:

graph g { edge "François" "Sørensen" } | Export-PSGraph -ShowGraph

The names show up with ? in strad of the european characters in Windows Powershell 5.1:
Not Working

But in Powershell 6.1 the image includes the correct european characters.

Working

@KevinMarquette
Copy link
Owner

My outputs is actually the output of dot.exe after passing it that simple digraph from your example. That is where the height and position info comes from. It's the default standard out when no image is specified.

I figured it was best to bypass Export-PSGraph while troubleshooting this one. I was unable to find a viable workaround in PowerShell 5.1 in my testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants