Javascript Non-Breaking Space Using Unescape

Hello Experts -
A while back I ran across a slick technique (that I can no longer locate) to insert a non-breaking space into a javascript variable.  I recall that it involved the use of unescape and worked something like this:
var space = unescape('###');
var string = 'Hello world. ' + space + 'How are you?';

Open in new window

My objective was to render two spaces between sentences in a javascript variable.  With   rendered by javascript literally, a more creative solution is needed to get the double-spaced effect.  Can someone give me an assist with what the '###' should be above to make this work?

I know that there are ways to accomplish this using createTextNode but this technique strikes me as easier. Thanks in advance.

-- Rick
MinnRickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nap0leonCommented:
Like this?

<html>
<body>
<script language="javascript">
var space = unescape('&nbsp;&nbsp;');
var string = 'Hello world.' + space + 'How are you?';
document.write(string);
</script>
</body>
</html>

Open in new window


It outputs HTML "Hello world.&nbsp;&nbsp;How are you?"
Which displays as "Hello world.  How are you?"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MinnRickAuthor Commented:
Thanks.  Although that wasn't what I was looking for (it was a 3-character, unicode-looking string), that works.  I also realized that I needed to write the jquery using the html() function rather than text().  Thanks for the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.