Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Nostale
You last visited: Today at 09:50

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Problem displaying entity names

Discussion on Problem displaying entity names within the Nostale forum part of the MMORPGs category.

Reply
 
Old   #1
 
Hatz~'s Avatar
 
elite*gold: 0
Join Date: May 2020
Posts: 370
Received Thanks: 450
Problem displaying entity names

Hello, i'm trying to display monster names on a qt gui but there are some special characters like "á, é, í, ó, ú and ñ" that are not being displayed correctly, does anyone know how to fix it? I've tried to google for a solution but most of the things i've found are related to console changes.

Image:
Hatz~ is offline  
Old 12/19/2020, 00:00   #2
 
Limoo's Avatar
 
elite*gold: 0
Join Date: Jan 2017
Posts: 475
Received Thanks: 192
Use different encoding
Limoo is offline  
Thanks
1 User
Old 12/19/2020, 00:16   #3
 
Hatz~'s Avatar
 
elite*gold: 0
Join Date: May 2020
Posts: 370
Received Thanks: 450
I've tryed using UTF-16 but it's displaying some random chinese characters
Hatz~ is offline  
Old 12/19/2020, 00:37   #4
 
elite*gold: 0
Join Date: Oct 2018
Posts: 257
Received Thanks: 207
What you want to use is UTF-8
Apourtartt is offline  
Thanks
2 Users
Old 12/19/2020, 08:41   #5
 
Hatz~'s Avatar
 
elite*gold: 0
Join Date: May 2020
Posts: 370
Received Thanks: 450
Uhm but isn't char strings already UTF-8? Sorry if this might looks like a very beginner question xD

Edit: so i've tried printing the names on a MessageBox and it was showing correctly there so the problem might be on the QString that is not on UTF-8 right? I've tried to use the method QString::fromUtf8() but didn't work

This is how im reading the char string:
Code:
MessageBoxA(NULL, mob->MonsterNamePtr->name, "", 0); // This shows correct name
ui->listWidget_2->addItem(mob->MonsterNamePtr->name); // This shows incorrect name
Hatz~ is offline  
Old 12/20/2020, 23:12   #6
 
WalrossGreat's Avatar
 
elite*gold: 0
Join Date: Mar 2015
Posts: 871
Received Thanks: 1,229
The strings in game are encoded with your default windows encoding (which is used by MessageBoxA), the QString operates on utf-8, you can use the QString::fromLocal8Bit to convert the native encoded char* to utf-8 QString
WalrossGreat is offline  
Thanks
1 User
Old 12/20/2020, 23:51   #7
 
Hatz~'s Avatar
 
elite*gold: 0
Join Date: May 2020
Posts: 370
Received Thanks: 450
I managed to make it work aswell with QString::fromLatin1 but thanks anyways
Hatz~ is offline  
Old 01/09/2021, 22:15   #8
 
Hatz~'s Avatar
 
elite*gold: 0
Join Date: May 2020
Posts: 370
Received Thanks: 450
Heya, now im trying to read/write stuff to a file and im facing the next issue, when i write to a file from a QString the entity name is being saved and displayed correctly on the file but when I read that same name from the file and try to convert it to a QString using QString::fromLatin1 or QString::fromLocal8Bit characters like "á, é, í, ó, ú" are not being displayed correctly.

Example of writing:

Example of reading:

If someone can help me i'd be very thankfull
Hatz~ is offline  
Old 01/09/2021, 22:34   #9

 
elite*gold: 64
Join Date: May 2011
Posts: 1,229
Received Thanks: 854
Why don't simply use the File-Class of QT?


(All untested)

Code:
    QFile file("out.txt");
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return;

    QTextStream out(&file);
    out << "The magic number is: " << 49 << "\n";
Else try it with std::wstring instead of std::string.

Code:
QString sMyQtString = "test";

std::wofstream f(L"C:\\some file.txt");
f << sMyQtString.toStdWString();
f.close();
BladeTiger12 is offline  
Thanks
1 User
Old 01/10/2021, 15:31   #10
 
Hatz~'s Avatar
 
elite*gold: 0
Join Date: May 2020
Posts: 370
Received Thanks: 450
I didn't even know that Qt had that class . It worked very well ty for your help
Hatz~ is offline  
Old 01/10/2021, 16:38   #11

 
elite*gold: 64
Join Date: May 2011
Posts: 1,229
Received Thanks: 854
Qt has everything you'll need. Really everything. Even 3D stuff / game rendering / Microcontroller etc... When I used it I never had one row with STD-library stuff.
BladeTiger12 is offline  
Reply


Similar Threads Similar Threads
Beginner Java: Displaying a 2D background
02/19/2012 - Tutorials - 0 Replies
Displaying a 2D Background Difficulty: 2 / 10. Assumed Knowledge: basic knowledge of the Java language. Information: This tutorial will teach you how to create a basic API and display an image. What is an API..? An application programming interface (API) is an interface implemented by a software program that enables it to interact with other software. It facilitates interaction between different software programs similar to the way the user interface facilitates interaction between...
C# displaying charname problem
04/08/2011 - SRO Coding Corner - 5 Replies
Hey guys, I've got some problems at the moment, im creating a information bar , or how to call it that shows my HP and MP and name ect ect... But at the moment it only display the first letter of my name and servername, sometimes it shows everything and sometimes it shows nothing ... Here is the code for my char name string charactername = mem.ReadString(0xF9E9B8);
[Question]Displaying Packets
01/11/2009 - CO2 Private Server - 1 Replies
just asking how to put that option back in there to display packets in the console Help is appreciated and THanx



All times are GMT +1. The time now is 09:51.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.