Closed OlingCat closed 7 months ago
Have you tried clearing the cache?
Have you tried clearing the cache?
Aha! That's the point! Just make clobber
and then build passed.
Thank you!
Build passed on Arch in WSL, but still didn't work on Windows. This may appear on a non-English Windows system. I'll try to change my system language into English and try again.
Conclusion:
If you are on a non-English Windows system, execute chcp 65001
in your cmd/PowerShell before make build
.
Could we detect if we're on Windows with a non-English system language in the Makefile and run chcp 65001
?
Could we detect if we're on Windows with a non-English system language in the Makefile and run
chcp 65001
?
I found a pwsh function called Get-WinSystemLocale | select -ExpandProperty Name
, this may help.
Even thought I think it's OK to set chcp 65001
for all language versions of Windows including English (en-US), this basically tell the terminal to use UTF-8 encoding text, which is compatible with English.
But on Chinese (zh-CN) Windows system, the default terminal encoding is GBK, which is not compatible with UTF-8, so we should run chcp 65001
to change the standard I/O stream encoding into UTF-8.
Great! So it's just a matter of detecting Windows, I suppose, which, I believe, is easily done.
Great! So it's just a matter of detecting Windows, I suppose, which, I believe, is easily done.
I just wrote a makefile
to do this. Feel free to add the following code to your makefile
in the proper style:
# Check if on Windows
ifeq ($(OS),Windows_NT)
CHCP := $(WINDIR)\System32\chcp.com
endif
.PHONY: build
build:
# Change console page code to 65001 (UTF-8).
ifdef CHCP
$(CHCP) 65001
endif
The following would probably be fine:
.PHONY: build
build:
ifeq ($(OS),Windows_NT)
# Change console page code to 65001 (UTF-8).
$(WINDIR)\System32\chcp.com 65001
endif
Do you know if the absolute path to chcp is necessary?
Do you know if the absolute path to chcp is necessary?
I think it may not be necessary. Your way is better.
Try to
make build
again and encountered the following error: