Warum zeigt mein Schachprogramm Fragezeichen (?) anstelle von Unicode-Schachfiguren an?
Posted: 20 Jan 2025, 16:53
Ich arbeite an einem Schachspiel in C++, das das Brett in der Konsole mit Unicode-Schachsymbolen anzeigt. Anstatt jedoch die weiße Dame (♕), die schwarze Dame (♛) und andere Unicode-Schachfiguren anzuzeigen, zeigt das Programm Fragezeichen (?) an. Unten ist mein Code
Code: Select all
#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