Anonymous
Почему моя шахматная программа отображает вопросительные знаки (?) вместо шахматных фигур Юникода?
Сообщение
Anonymous » 21 янв 2025, 09:21
Я работаю над шахматной игрой на C++, которая отображает доску в консоли с использованием шахматных символов Юникода. Однако вместо того, чтобы показать чёрного ферзя (
), белая королева (
) и других шахматных фигур Unicode, программа отображает вопросительные знаки (
).
Ниже мой код:
Код: Выделить всё
#include "ChessGame.h"
#include
#include
#include
#include
#include
using namespace std;
const wchar_t* pieces[7] = { L"♕", L"♙", L"♖", L"♘", L"♗", L"♕", L"♔" };
const wchar_t* blackPieces[7] = { L"♛", L"♟", L"♜", L"♞", L"♝", L"♛", L"♚" };
ChessGame::ChessGame() : whiteTurn(true) {
board = { {
{-5, -3, -4, -7, -6, -4, -3, -5},
{-1, -1, -1, -1, -1, -1, -1, -1},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 1, 1, 1},
{ 5, 3, 4, 7, 6, 4, 3, 5}
} };
}
void ChessGame::run() {
SetConsoleOutputCP(CP_UTF8);
wcout.imbue(locale("en_US.UTF-8"));
while (true) {
printBoard();
wcout > end;
int startX = start[0] - 'a';
int startY = 8 - (start[1] - '0');
int endX = end[0] - 'a';
int endY = 8 - (end[1] - '0');
if (isMoveValid(board[startY][startX], startX, startY, endX, endY)) {
processMove(startX, startY, endX, endY);
whiteTurn = !whiteTurn;
} else {
wcout
Подробнее здесь: [url]https://stackoverflow.com/questions/79371907/why-does-my-chess-program-display-question-marks-instead-of-unicode-chess-pi[/url]
1737440462
Anonymous
Я работаю над шахматной игрой на C++, которая отображает доску в консоли с использованием шахматных символов Юникода. Однако вместо того, чтобы показать чёрного ферзя ([code]♕[/code]), белая королева ([code]♛[/code]) и других шахматных фигур Unicode, программа отображает вопросительные знаки ([code]?[/code]). Ниже мой код: [code]#include "ChessGame.h" #include #include #include #include #include using namespace std; const wchar_t* pieces[7] = { L"♕", L"♙", L"♖", L"♘", L"♗", L"♕", L"♔" }; const wchar_t* blackPieces[7] = { L"♛", L"♟", L"♜", L"♞", L"♝", L"♛", L"♚" }; ChessGame::ChessGame() : whiteTurn(true) { board = { { {-5, -3, -4, -7, -6, -4, -3, -5}, {-1, -1, -1, -1, -1, -1, -1, -1}, { 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0}, { 1, 1, 1, 1, 1, 1, 1, 1}, { 5, 3, 4, 7, 6, 4, 3, 5} } }; } void ChessGame::run() { SetConsoleOutputCP(CP_UTF8); wcout.imbue(locale("en_US.UTF-8")); while (true) { printBoard(); wcout > end; int startX = start[0] - 'a'; int startY = 8 - (start[1] - '0'); int endX = end[0] - 'a'; int endY = 8 - (end[1] - '0'); if (isMoveValid(board[startY][startX], startX, startY, endX, endY)) { processMove(startX, startY, endX, endY); whiteTurn = !whiteTurn; } else { wcout Подробнее здесь: [url]https://stackoverflow.com/questions/79371907/why-does-my-chess-program-display-question-marks-instead-of-unicode-chess-pi[/url]