How can I set my GHCi prompt to a lambda character on Windows?

落花浮王杯 提交于 2019-11-27 13:44:39

问题


I want to have a lambda (λ) symbol as my prompt in GHCi (7.8) on Windows 7, so I set up my .ghci file as

:set +m
:set prompt  "λ: "
:set prompt2 " | "

And I set my console font to Lucida Console since it's supposed to support Unicode, but when I load up GHCi, it looks like this instead

How can I get Windows to recognize the λ symbol properly?


回答1:


Using > chcp.com 65001 worked with ghci but opening other text files with vim after setting that code page returned garbled text.

Add the following to your %USERPROFILE%\.ghci. Instead of changing the code page you can use unicode escaped lambda \x03BB:

:set prompt  "\x03BB: "

If %USERPROFILE%\.ghci does not exist create it before making the change.




回答2:


This is actually quite a simple fix, just run the following command before starting GHCi:

> chcp.com 65001

This sets Window's encoding to the 65001 code page, which lets the λ get displayed properly:

This will also let a lot of other Unicode characters be displayed properly in cmd.exe and other Windows shells (such as Cygwin bash), but Windows' Unicode support is still not perfect, and some fonts don't support many of the characters. Luckily, λ happens to be a supported character so we can all have the classic GHCi prompt.



来源:https://stackoverflow.com/questions/25373116/how-can-i-set-my-ghci-prompt-to-a-lambda-character-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!