cancel
Showing results for 
Search instead for 
Did you mean: 

string in textarea

JNova.0
Associate III
Hello,
I use resources and everything works there.
Now I need to display text from code and I came across that the result of these commands is
 
23???
 
what is wrong with this code? What do I need to set where?
 

 

 

 

int intvalue_ = 23;
std::string stringvalue_ = "Hello";
Unicode::snprintf(textAreaBuffer, TEXTAREA_SIZE, "%d %s", intvalue_, stringvalue_ );
textArea.setWildcard(textAreaBuffer);

 

 

 

 
textArea has Typography BigFont selected in the designer
I have Wildcard Ranges in the Typography settings for BigFont
0-9,a-z,A-Z
 
It will definitely be something small.
Can you advise?
 
I found this sample, but even here the question mark appears

 

    Unicode::UnicodeChar a[] = {0x00B0,0};
    uint16_t degree = 28;
    Unicode::snprintf(textArea1Buffer, TEXTAREA1_SIZE, "%d %s", degree, a);
    textArea1.invalidate();

 

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

Hi JN

In your second try, set wildcard range for example 0x20-0xB0, now it missing the space (0x20) and 0xB0 (degree sign). Then it should work.

In first trial, the Unicode::snprintf can understand correctly only 16 bit strings so must first copy your 8 bit char string with Unicode::strncpy to unicode- array. Like this:

 

	int intvalue = 23;
	Unicode::UnicodeChar stringvalue[10];
	
	Unicode::strncpy(stringvalue, "Hello",10);
	
	Unicode::snprintf(textAreaBuffer, TEXTAREA_SIZE, "%d %s", intvalue,stringvalue );
    textArea.invalidate();

 

Note that you can also do like this when need only to put free text to wildcard:

 

	Unicode::strncpy(textAreaBuffer, "Hello",TEXTAREA_SIZE);
    textArea.invalidate();

 

 

Br JTP

View solution in original post

1 REPLY 1
JTP1
Lead

Hi JN

In your second try, set wildcard range for example 0x20-0xB0, now it missing the space (0x20) and 0xB0 (degree sign). Then it should work.

In first trial, the Unicode::snprintf can understand correctly only 16 bit strings so must first copy your 8 bit char string with Unicode::strncpy to unicode- array. Like this:

 

	int intvalue = 23;
	Unicode::UnicodeChar stringvalue[10];
	
	Unicode::strncpy(stringvalue, "Hello",10);
	
	Unicode::snprintf(textAreaBuffer, TEXTAREA_SIZE, "%d %s", intvalue,stringvalue );
    textArea.invalidate();

 

Note that you can also do like this when need only to put free text to wildcard:

 

	Unicode::strncpy(textAreaBuffer, "Hello",TEXTAREA_SIZE);
    textArea.invalidate();

 

 

Br JTP