# Adding blank space at the end of string

**URL:** <https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410>\
**Category:** General\
**Created:** [July 2, 2018, 2:39pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410 "2018-07-02T14:39:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monden](https://casparcgforum.org/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Monden](https://casparcgforum.org/u/Monden)\
**Post date:** [July 2, 2018, 2:39pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/1 "2018-07-02T14:39:14Z")

</div>

Hi,

I need help with adding blank space at the end of string. I tried to append text " ", but it doesn’t work. Blank space always gets trimmed if it’s at the end of string. So, how do I work this around?

Thank you.

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 2, 2018, 4:34pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/2 "2018-07-02T16:34:42Z")

</div>

Were do you want to add it? To a textfield in Flash? In HTML? To you dogs tail? Please provide a bit more informations as we cannot read your mind.

---

<div class="post-metadata">

**Author:** ![Monden](https://casparcgforum.org/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Monden](https://casparcgforum.org/u/Monden)\
**Post date:** [July 2, 2018, 7:56pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/3 "2018-07-02T19:56:02Z")

</div>

To my dogs tail, obviously.

Textfield, of course. Flash/AS3

---

<div class="post-metadata">

**Author:** ![silid](https://casparcgforum.org/user_avatar/casparcgforum.org/silid/32/22_2.png) [@silid](https://casparcgforum.org/u/silid)\
**Post date:** [July 2, 2018, 8:17pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/4 "2018-07-02T20:17:35Z")

</div>

You are going to have to describe your problem in more detail.

Do you have any code examples to share?

How do you know that the space has been stripped?

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 2, 2018, 9:14pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/5 "2018-07-02T21:14:47Z")

</div>

> [@Monden](#):
>
> To my dogs tail, obviously.

I am afraid, that‘s what I expected.

No seriouse. I do that in code. Sometimes that is needed, as the font has a weird spacing and get cut of. I is possible, that the client trims it, so you should add the space inside the template. Can you post your .fla and .as file (not the .ft)?

---

<div class="post-metadata">

**Author:** ![Monden](https://casparcgforum.org/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Monden](https://casparcgforum.org/u/Monden)\
**Post date:** [July 3, 2018, 12:33am UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/6 "2018-07-03T00:33:19Z")

</div>

Ok, sorry. I definitely need to provide you with more information.

I have created a text field in Flash, which is being filled from the client (Caspar Client). To the text that I’m entering from the client, I need to add blank space, at the end of it, using ActionScript. So what I need to get is: “text” + " " = "text ".

This is what I have tried so far:

textfield.text += " ";

textfield.appendText(" ");

var blankspace:String = " ";  
textfield.appendText(blankspace);

I’ve even tried adding blank space from Unicode:

textfield.appendText(32);  
textfield.appendText(160);

Every time the blank space at the end of the text gets trimmed. Same thing happens when I enter a text with the blank space at the end in the Client.

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 3, 2018, 6:53am UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/7 "2018-07-03T06:53:54Z")

</div>

Were is that code residing? Are you sure, that the texfield has it‘s text set before your code runs?

---

<div class="post-metadata">

**Author:** ![Monden](https://casparcgforum.org/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Monden](https://casparcgforum.org/u/Monden)\
**Post date:** [July 3, 2018, 9:22am UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/8 "2018-07-03T09:22:35Z")

</div>

The code is in the external AS3 class.

package  
{  
import flash.display.MovieClip;  
import se.svt.caspar.ICommunicationManager;  
import se.svt.caspar.IRegisteredDataSharer;  
import se.svt.caspar.template.CasparTemplate;

```
public class testblanko extends CasparTemplate
{
	override public function SetData(xmlData:XML):void
	{
		super.SetData(xmlData);
		for each (var element:XML in xmlData.children())
		{
			if (element. @ id == "tekst")
			{
				var pom:String = String.fromCharCode(160);
				tekst.appendText(pom);
			}
	    }
		
	}
}

```

}

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 3, 2018, 9:32am UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/9 "2018-07-03T09:32:54Z")

</div>

Try this:

```
public class testblanko extends CasparTemplate
{
	override public function SetData(xmlData:XML):void
	{
		super.SetData(xmlData);
		for each (var element:XML in xmlData.children())
		{
			if (element.@id == "tekst")
			{
				tekst.text = element.data.@value.toString() + " ";
			}
	    }
		
	}
}
```

---

<div class="post-metadata">

**Author:** ![Monden](https://casparcgforum.org/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Monden](https://casparcgforum.org/u/Monden)\
**Post date:** [July 3, 2018, 12:04pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/10 "2018-07-03T12:04:46Z")

</div>

Tried it. Same thing. Still trims it. I think the problem is not the syntax, but some kind of s setting in the Client or on the Server that automatically trims blank space at the end of the text, cause even when I enter "text " (with the blank space at the end) for the value of the textfield in the Client it still gets trimmed.

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 3, 2018, 12:24pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/11 "2018-07-03T12:24:08Z")

</div>

…and you are sure, that you added the class in your .fla file, so that it finds the .as file? Because doing it that way must work.  
 ![Grab2](https://casparcgforum.org/uploads/default/original/1X/d047d18a08dc15599c19146272cf10f39ff3348e.PNG)

In the red circle goes the name of the class in your case testblanko.

---

<div class="post-metadata">

**Author:** ![Monden](https://casparcgforum.org/letter_avatar_proxy/v4/letter/m/258eb7/32.png) [@Monden](https://casparcgforum.org/u/Monden)\
**Post date:** [July 3, 2018, 2:30pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/12 "2018-07-03T14:30:22Z")

</div>

Of course. ![testblanko1](https://casparcgforum.org/uploads/default/original/1X/da3005c5244228c6d9c341bccf2424af04d54dd6.jpg)

---

<div class="post-metadata">

**Author:** ![didikunz](https://casparcgforum.org/user_avatar/casparcgforum.org/didikunz/32/7_2.png) [@didikunz](https://casparcgforum.org/u/didikunz)\
**Post date:** [July 3, 2018, 6:15pm UTC](https://casparcgforum.org/t/adding-blank-space-at-the-end-of-string/410/13 "2018-07-03T18:15:44Z")

</div>

Can you upload the two files somewhere?
