p>
let suitSymbol = function
| Spades -> "\u2660"
| Clubs -> "\u2663"
| Diamonds -> "\ u2666"
| Hearts -> "\u2665"
Show this use
printf "%s" <| suitSymbol Spades
It works fine in fsi:
But when When compiled with fsc.exe, it will display different (unsuitable) characters:
I have tried to change the encoding of the source file, but it has no effect. Is there a way to make it work at compile time?
Edit (30.01.2017):
Stuart's anwser is correct, but I can’t understand it, it needs to be entered
chcp 65001 pre>Every time I want to run my game.
After studying the method of referencing DLL in F#, I came up with the following solution:
module Kernel =
[]
extern bool SetConsoleOutputCP(uint32 wCodePageID)In the main function code I added
[]
let main args =
Kernel.SetConsoleOutputCP 65001u |> ignoreIt only modifies the code page of this process, so other applications will run normally.
chcp 65001
After some tests, I can Reproduce your problem and solve it. Credit to @s952163
I am making a console-based card game with f#, and I am trying to use unicode chars Show card suits. Mapping suit-to-char represents the following function:
let suitSymbol = function
| Spades -> "\u2660"
| Clubs -> "\u2663"
| Diamonds -> "\u2666"
| Hearts -> "\u2665"
Show this usage
printf "%s" <| suitSymbol SpadesIt works fine in fsi:
but When compiled with fsc.exe, it will display different (unsuitable) characters:I have tried to change the encoding of the source file, but it has no effect. Is there a way to make it work at compile time?
Edit (30.01.2017):
Stuart's anwser is correct, but I can’t understand it, it needs to be enteredchcp 65001 pre>Every time I want to run my game.
After studying the method of referencing DLL in F#, I came up with the following solution:
module Kernel =
[]
extern bool SetConsoleOutputCP(uint32 wCodePageID)In the main function code I added
[]
let main args =
Kernel.SetConsoleOutputCP 65001u |> ignoreIt only modifies the code page of this process, so other applications will run normally.
At the command prompt, you need to change the code page , As follows:
chcp 65001After some tests, I was able to reproduce your problem and solve it. Credit to @s952163