2

I just changed a classic asp page to load a div with some data via jquery.load

This calls another classic asp page that returns the contents of what should be in the div.

The code does looks like this:

<span class="ord-val"><%= FormatCurrency(OrderValueMonth) %></span>

When this code was inline in the orginal page, it worked fine, but since I changed it, it now displays like this:

incorrect thousand separator using south african locale

The jquery code to load the html looks like this:

    $("a#ord").click(function () {
        $("#tab").load('dashorder.asp?<%= strQuerystring %>');
    });

At first I thought that could be a charset problem, but using fiddler I can see that the content-type for all the loaded content is "UTF-8".

Is there something else I can check?

Nils
  • 1,237
  • 3
  • 11
  • 28

4 Answers4

0

The solution here is a either avoid using <meta charset="utf-8"/> for your project

remove it from your head tags or leave it blank

<meta charset=""/>
gabisajr
  • 146
  • 1
  • 5
0

That function uses the symbol defined in the computer's control panel, can you confirm what character you're using? If it's a non-standard character, you may want to replace() is with a comma, or assuming rubles, a white space, eg:

<span class="ord-val"><%= replace(FormatCurrency(OrderValueMonth),"YOURCHAR"," ") %></span> 
HeavenCore
  • 7,533
  • 6
  • 47
  • 62
  • The code does work fine when I don't load it from jquery. For the locale above, it's set to be a space. i.e. it should show as: R 25 413,74 – Nils Feb 28 '12 at 13:49
  • 1
    Is it definitely a space? for instance, what happens if you output this: server.encodeurl(FormatCurrency(OrderValueMonth)) For instance, a space would be %20 – HeavenCore Feb 28 '12 at 13:51
  • the space shows as %A0 which seems to be a non-breaking space... The question is: how would I change this? And also, why would this only start happening when I introduced the jquery load call? I see this question on SO: http://stackoverflow.com/questions/6192788/difference-between-and-a0-urlencoding but my encoding seems to be consistent? – Nils Feb 28 '12 at 14:05
  • 1
    I'd imagine that the inline %A0 is rendered as a standard   by the browser, whereas, passing this through javascript does not. I'd suggest replacing the nbsp with a normal space on the asp, eg: replace(FormatCurrency(OrderValueMonth),CHR(160)," ") – HeavenCore Feb 28 '12 at 14:19
  • Thanks +1 because your solution achieves the desired effect, but I'm really after the source of the problem so that I can fix it for any further problems using jquery's ajax loading. I think the real solution is to not use utf-8. – Nils Feb 28 '12 at 14:36
  • Are you 100% definitely sure that both the host page and the ajax back end page are using utf8 content types? If so, just a hunch, try adding the following into the host page: – HeavenCore Feb 28 '12 at 14:44
0

Use this function over the outputted string that is r25?413,74

Sub ExposeAllChars(sInput)

    Dim MaxLength,i,curChar

    MaxLength = Len(sInput)

    For i = 1 To MaxLength
        curChar = Mid(sInput, i, 1)
        Response.write "<li>[" & curChar & "]=[" & Asc(curChar) & "]"

    Next

End sub

And you'll now what ascii char is the culprit. then you do a replacement string on that ascii char like this

replace(OrderValueMonth,asc(the_culprit_char_ascii_number_here),a_reasonable_replacement_for_that_char,1,-1,1)

HTH

Average Joe
  • 4,521
  • 9
  • 53
  • 81
0

With help from @HeavenCore's comments, I've stumbled onto this link jQuery AJAX load and encoding/charset problems

I think that's the best solution because it means thatif I run into further issues, I won't have to end up replacing every instance of the problem.

In my case I fixed the problem by changing the charset to <% Response.CharSet = "windows-1252" %> for this locale.

Here's a link to a list of character sets Character sets list

Nils
  • 1,237
  • 3
  • 11
  • 28