Ralph Romero

Blog

Displaying International Characters in the F# Console

Posted at — Dec 1, 2020

When outputting non-English characters in an F# console, you may find that the characters are unrepresentable. For example

printfn "あそこで買う"
printfn "ليونيكود"
printfn "медве́дем"
printfn "Hồ Xuân Hương"

gives you

??????
????????
?????´???
H? Xuân Huong

To correct this, set the output encoding before the output

System.Console.OutputEncoding <- System.Text.Encoding.Unicode
printfn "あそこで買う"
printfn "ليونيكود"
printfn "медве́дем"
printfn "Hồ Xuân Hương"

then run the console. Click on the top left icon on the console window and select Properties. Change the font to SimSun-ExtB. You should see the characters displayed properly.

あそこで買う
ليونيكود
медве́дем
Hồ Xuân Hương