I am trying to insert a special unicode character (0xFD3F) into a QString.
I tried to create QChar(0xFD3F) but when outputting this char and viewing it in a hex editor it shows 0x3F3F.
I couldn't also find a function in QString to insert a character by its hex or decimal representation.
Use QString::fromWCharArray like this:
QString::fromWCharArray(L"Hello \uFD3F Good bye")
Use QString::fromUtf8 like this:
QString::fromUtf8("Hello \uFD3F Good bye")
Related
It's the code I'm printing with node:
const m = `[38;5;1;48;5;16m TEST`
console.log(m)
output:
It changes the text color.
As you can see `` is a special char I don't understand(It's not being shown by the browser). How does it work?
Is there any alternative for ESC?
As #puucee already mentions they are terminal control characters. I find it surprising that it says ESC[ in the code as that won't be escaped in normal node. I suspect that maybe your IDE is converting the "true" escape character to ESC. Node does not support octal escapes (such as \033), but hexadecimal escapes. That is, you string should usually be like this:
console.log('\x1b[38;5;1;48;5;16m TEST \x1b[0m')
These are terminal control characters. They are often used e.g. for coloring the output. Some are non-printable. Backticks ` in your javascript example are called template literals.
I have user-provided format string (e.g. "%.2f") and a QVariant type that I am attempting to combine to output into a (formatted) string.
I had gone down the path of using QString::asprintf(const char *cformat, ...) to achieve this, where I would supply the appropriate converted data type, like this:
QString result_str = QString::asprintf(disp_fmt.toUtf8(),variant_type.toUInt());
This works fine for the most part, especially when I have a floating point as the input. However, if my format string in this particular integer (.toUInt()) conversion case includes decimal formatting (e.g. "%.2f"), then I get a constant result of "0.00". This caught me by surprise as I expected to instead just get ".00" tacked onto the integer, as I have seen in other languages like Perl.
What am I missing here? Also, I know asprintf() was added fairly recently and the documentation already now advises to use QTextStream or arg() instead. I don't believe this to be an option, however, for me to use this style of format string. Thanks.
The format string is expecting a double, but you're providing an int. It works if you provide an actual double, like this:
QString result_str = QString::asprintf(disp_fmt.toUtf8(),variant_type.toDouble());
Also note, this behavior is identical to how the standard C library functions work (std::sprintf, etc).
I am currently trying to correct pronunciation of a word using dictionary called userdct_eng.dct which later will be converted to .dat file using python.
My problem is I don't know how to modify the pronunciation of an input word which enclosed in double quotes (").
this is the example code inside the dictionary:
[Header]
Name=userdct_eng.dct
Description=userdct_eng
Language=ENG
Content=EDCT_CONTENT_BROAD_NARROWS
Representation=EDCT_REPR_SZZ_STRING
[Data]
you // #'jEs#
"you" // #'jEs#
I am trying to modify word you to pronounce as yes. it's work, this string ( you // #'jEs# ) is working.
And in the second string I am trying to modify word "you" (including the double quotes) to pronouncing as yes. but it doesn't, this string ( "you" // #'jEs# ) doesn't work, the voice still pronounce it as you.
my question is: How to deal with double quotation marks word?
thanks.
SOLVED by using backslash (\) before double quote (").
Example:
\"you\" // #'jEs#
Create a simple string in Scilab containing a newline.
Seems simple enough, but Scilab only seems to interpret escape sequences through printf style functions and msprintf / sprintf splits the string into a vector of strings at the newline!
The only way I can see to achieve this is to actually write a newline out to a file and read it back in again. Surely there is a simpler way to do this!
Ok, found it. The ascii function will do the job, a newline can be added via its ascii decimal -
str = 'hello' + ascii(10) + 'world'
I am having a problem where a Hebrew string is being displayed in reverse. I use QTableWidget to display some info, and here the string appears correctly using:
CString hebrewStr; hebrewStr.ToUTF8();
QString s = QString::fromUtf8( hebrewStr );
In another part of my program this same string is displayed on the screen, but not using QT, and this is what is being shown in reverse:
CString hebrewStr;
hebrewStr.ToUTF8();
I have debugged and hebrewStr.ToUTF8() in both cases produces the exact same unicode string, but the string is only displayed correctly in the QTableWidget. So I am wondering if Qt automatically reverses a given Hebrew string (since it is a rigth-to-left language). Thanks!
Yes, in this case QString generate the full unicode wchar_t from the UTF-8 encoded string. If you would like to do similar thing in MFC, you should use CStringW and decode the string.
Use MultiByteToWideChar for UTF8 to CStringW conversion.
Connected question in StackOverflow.