How to add spaces before or after string?

I noticed that Fuse trims spaces before and after strings. For example, although I write (notice the white space after each string Value):

<DockPanel>    
    <Text Value="Lorem " Dock="Left" />
    <Text Value="ipsum " Dock="Left"  />                    
    <Text Value="dolor " Dock="Left" />
    <Text Value="sit " Dock="Left"  />                    
    <Text Value="amet" Dock="Left" />
</DockPanel>

I get:

Loremipsumdolorsitamet

How to I add white spaces inside strings? I tried &nbsp; but I get undeclared entity. I know that there’s a Fuse statement Char but I don’t know how to call it inside a string (I guess I could call Char(32)).

I need to add white spaces because the API I’m working with returns dates splitted into three elements (day of the week, day of the month and year) and I would like to concatenate the result into a string. So I need to a space between each string. Without spaces I get:

April162017 rather than April 16 2017

Thonk you

Hi Enrico,

I’m fairly certain that if the whitespace is coming from JavaScript, it will not be trimmed. Meaning, you can add it there, in JS.

An alternative approach you could take is concatenating the string using UX expression syntax, like so:

<Text Value="{month} {day}, {year}." />

which then would produce e.g. April 16, 2017..

Thank you Uldis,

Yes you are right, concatenating the string using UX expression as in your example works properly:

<Text Value="{month} {day}, {year}." />

But trying to concatenate <Text> expressions as follows, will trim the space:

<DockPanel>    
    <Text Value="Lorem " Dock="Left" />
    <Text Value="ipsum " Dock="Left"  />                    
    <Text Value="dolor " Dock="Left" />
    <Text Value="sit " Dock="Left"  />                    
    <Text Value="amet" Dock="Left" />
</DockPanel>

Also, a simple:

<Text Value=" " Dock="Left" />

won’t print the space. In my opinion, as happens in HTML with &nbsp;, sometimes is useful to print a whitespace.

I can’t tell if the trimming of whitespace is or is not a bug, or expected behaviour.

I can, however, tell that Fuse probably does not and should not support named HTML entities in Text. I think that you could have some luck with HEX encoded entities, so maybe &#32; or something along those lines might achieve what you’re looking for.

With the tools in place to do string concatenation in JavaScript, as well as with UX expressions, I strongly believe that every possible use-case is covered.

Thank you Uldis!

&#32; works perfectly as expected.

If other users have the same issue, to add a white space inside UX it’s easy as:

<Text Value="Hello&#32;world!" />

that outputs:

Hello world!