27 views
in Embedded Wizard Studio by

Hi team,

I write you because I noticed there is an issue with char '%' and wanted to check it with you.

I was trying to show several variables of type char converted to string type and concatenated to form a displayable word (e.g. TextView.String = string(char1) + string(char2) + string(char3) +...). At this point, I realized that char '%' is never displayed (also tried with its unicode '\x0025' and same result). At first I thought that was due to missing the character in the declared font (Roboto), but then I tried displaying string "%%" and it does get displayed (situation 1), unklike strings "\x0025" and "%" (situation 2). I also tried other types of fonts and same situation happens. Here below you can find a very simple example of what I am doing to check:

SITUATION1:

Start:

Result:

 

SITUATION 2:

Start:

Result:

 

What I am doing wrong? Is it correct for this thing to happen? If not, how can I get char '%' to be displayed properly?

Thanks in advance for your help and best regards,

Fayna

P.S. Exactly same situation happens for char '^' (unicode '\x005E') and '~' (unicode '\x007E'); also checked with same results.

 

 

1 Answer

+1 vote
by
 
Best answer

Hi Fayna,

in order to be able to output the special characters '%', '^' and '~' as regular signs, the character '%' has to be applied in front of the affected sign to convert it to a regular sign. 

To show the '%' sign itself, use '%%' sequence. See also the section Specify the text.

Best regards,

Manfred Schweyer.

by

Hi Manfred,

Thanks for your response. I see your point and I have already tried that before posting the question, but it did not work. 

I tried this:

var char char1 = '%%'; 
TextView.String = string(char1);

But the next error is given back: 

>>Expected ' single quote sign to close the character literal. But instead of this a '%' sign has been found. The character literal has to begin with a ' single quote sign followed by the character itself and a second ' single quote sign.<<

Do you know a reason for this error?

Regards,

Fayna

by
Hi Fayna,

in this case you have to check the single characters if it is a special character and add an additional "%" to the string before adding the special character.

Regards,

Manfred.
by

Hi Manfred,

Thanks again for your response. 

I hope my request does not bother you, but I do not understand why it is necessary to do what you comment with some special characters but not with others. For example, characters '{' and '&', and even '$$', '\"' or '\\', can be displayed correctly when converted to string, but what is the point with '^', '~' and '%'? They cannot be declared like other special characters, as explained in Data type: char. Literal syntax, so there is no syntax consistance when using them. Can this be solved without the use of extra string "%" before the character to be displayed? I am trying to avoid the use of extra strings in my code to display the characters (I just want to declare the characters, convert them into string without any addition and concatenate them).

Regards,

Fayna

by

Hi Fayna,

I suspect two things are being mixed up here...

The data type char represents a single 16-bit character. The special characters as mentioned in the description of the data type char are escape sequences to use them instead of a character code. For example you can use in your code the character '\n' instead of using the code 0x000A. It is still a 16-bit character.

The text view supports a few special characters that can be used to control the text output:

  • The signs ~ (tilde) are treated as soft-hyphens. They determine potential candidates to wrap a word. These signs are not displayed until the text wrap took place at their position. In such case the affected text row is terminated with an additional hyphen - sign indicating that the word has been broken there.
  • The signs ^ (circumflex) are treated as silent soft-hyphens. They determine potential candidates to wrap a word. These signs are never displayed nor replaced by any hyphen even if the text wrap took place at their position. They are simply silent.
In order to display the tilde or the circumflex, the percent character has to be used - you have to prefix it within the string explicitly by an additional % (percent) character. This applies also to the percent character itself.
This means, to display a % sign within a text view, you need to have two consecutive % characters within the string. This two % characters cannot be stored in one variable of the data type char.
I hope I was able to explain it a bit.
Best regards,
Manfred. 
by
Hi Manfred,

Thanks for your response. Now I understand what you mean and I will apply the proper changes to display "%", "~" and "^".

Thank you for taking your time to answer every reply.

Best regards,

Fayna

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...