Developer forum

Forum » Templates » .JSEncoded() is buggy

.JSEncoded() is buggy

Sten Hougaard
Reply

Hi,

The introduction of "JSEncoded()" template extension is great when working with JSON data build from Dynamicweb templates.

It however seem that it is not doing a perfect job.

If I for instance aske to get a JSEncoded value from

 

"Stressless Eldorado høj

..."

 

It will return:

"Stressless Eldorado høj\r\n..."

 

which is not 100% correct. I did HTML encoding, Not Javascript encoding of the danish "ø".

The correct encoding would be:

"Stressless Eldorado h\u00f8j\r\n..."

You can try out my online webapp which will encode a given value in various formats:

 

 

Med venlig hilsen / Kind regards

 

Sten Hougaard

Webdeveloper

727 Online as 

www.727.dk

 


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

I cannot reproduce this behavior.

Are you sure that the value does not contain "ø" before you're calling JSEncoded? This will probably be the case when the value comes from a rich text editor in Dynamicweb.

Best regards,
Mikkel

Votes for this answer: 1
 
Nicolai Høeg Pedersen
Reply

The JSEncoded extension method uses HttpUtility.JavaScriptStringEncode from the .NET library, so if it does not Work, the error would probably be in the  .NET framework....

 

http://msdn.microsoft.com/en-us/library/system.web.httputility.javascriptstringencode.aspx

 
Sten Hougaard
Reply

Hi Mikkel and Nicolai,

You are both right - and I failed on checking the source. It was stored like this:

Eldorado høj

Guess it would work as it is :-) Thanks!

/Sten

 

You must be logged in to post in the forum