Skip to content

Instantly share code, notes, and snippets.

@ytxmobile98
Created July 29, 2020 00:00
Show Gist options
  • Select an option

  • Save ytxmobile98/d2787e59b62c40a1e078ba94eec46264 to your computer and use it in GitHub Desktop.

Select an option

Save ytxmobile98/d2787e59b62c40a1e078ba94eec46264 to your computer and use it in GitHub Desktop.
Chinese output in C++
#include <iostream>
#include <cstring>
int main() {
setlocale(LC_ALL, "zh_CN.UTF-8");
const wchar_t test[] = L"abc我惊呆了123";
for (const auto& i: test) {
std::wcout << i << std::endl;
}
return 0;
}
CFLAGS := -g -Wall -Werror
target := Chinese
.PHONY: all
all: $(target).out
$(target).out: $(target).o
$(CXX) $^ -o $@
%.o: %.cpp
$(CXX) $(CFLAGS) $^ -c -o $@
.PHONY: clean
clean:
-rm -rfv *.o *.out
a
b
c
1
2
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment