Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36

Thread: Is it possible to make webserver play nice with special characters in variables?

  1. #1
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default Is it possible to make webserver play nice with special characters in variables?

    I have a problem with the webserver: When there are variables that contains special characters, like æøå (Norwegian), at least the ø (which is the one I'm using so far) is shown like a �. So a variable that should have been Kjøkken (kitchen) is instead shown as Kj�kken. Is it possible to get this to work? I have the web page in UTF-8, and stuff that is written in regular text works. But variables doesn't want to play nice. I tested with the demo that comes with Girder, and it seems like it's a problem within the webserver or somewhere between that and the generated webpage. Is it possible to get this working as it should?
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  2. #2
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    You are most likely not using the correct encoding. If it's displaying as a �. Check the headers that are returned and fix those or add a meta tag:

    http://www.w3schools.com/tags/att_meta_charset.asp

    Probably UTF-8 is incorrect, I assume your text editor is not creating proper UTF-8 files.

    http://scratchpad.wikia.com/wiki/Cha..._for_Languages

    Shows that ISO-8859-1 might work. Place this at the top of your HTML file inside the <HEAD> tags.

    Code:
     		<meta charset="ISO-8859-1">
    Ron
    No support through PM

  3. #3
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Thanks, Ron! But I'm afraid that didn't work. When I use that (or the -15 which is on the same page), it doesn't change the ø at all. Plain text works as it should, it's just those variables that won't work. I have tried with both notepad, Dreamweaver and Notepad++, all set to UTF-8, and I get the same result from them all.

    The start of my file look like this, with the charset changed:

    Code:
    <html><head>
    <meta http-equiv="PRAGMA" content="NO-CACHE">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Temperaturstyring</title>
    That works without problems, except for the carbled variable for ø. If I do this:

    Code:
    <html><head>
    <meta charset="ISO-8859-1">
    <meta http-equiv="PRAGMA" content="NO-CACHE">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Temperaturstyring</title>
    I get exactly the same result. Even deleting the one after content doesn't change anything.
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  4. #4
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Show us the file!
    Ron
    No support through PM

  5. #5
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    With pleasure, sir! I've removed your meta again for now since it didn't seem to change anything. It's attached as a text file, since it's too long for the message.
    Attached Files Attached Files
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  6. #6
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    which line creates the offending characters?
    Ron
    No support through PM

  7. #7
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Code:
    //as above, but with letters (does not update unless page is reloaded)
    var myname_REF = '<center><Div><Span id=\"mynameID'+RowID+'\"></span></center>';
    $('<td style=\"text-align: center; vertical-align: middle; width: 110px; height: 36px;\">'+myname_REF+'</td>').appendTo(tr);
    It takes the room names from this table:

    Code:
    Temperaturstyring.Nettside.Rom ={
    [1] = "WC",
    [2] = "Garderoberom",
    [3] = "Midtsoverom",
    [4] = "Hjørnesoverom",
    [5] = "Hovedsoverom",
    [6] = "Bad",
    [7] = "Stue",
    [8] = "Kjøkken",
    [9] = "Kino",
    [10] = "Biljardrom",
    [11] = "Kjellerkontor",
    [12] = "Treningsrom",
    [13] = "Gjesterom",
    }
    Edit: The table goes into the variable on the webpage via this line:

    Code:
    $(document).ready(function() { setTimeout('checkGIRDER(\'Temperaturstyring.Nettside.Rom\',\'myname\',\'csv\',\'false\')',200); });
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  8. #8
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Ah ok. It might be the encoding of the ajax-request that is wrong.

    ajaxreqjson.lhtml

    show us that file.
    Ron
    No support through PM

  9. #9
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Certainly, boss!

    Code:
    <%
    
    
    function getfield (f)
        local v = _G    -- start with the table of globals
        for w in string.gfind(f, "[%w_]+") do
            if type(v) == 'table' then --v ~= nil
                v = v[w]
            else
                return false
            end
        end
        return v
    end
    
    local s,vartype
    local t = webserver:GetCGI()    
    
    if t.Data then
      local json = require('json.json')
      local data = string.Split(t.Data,",")
      webserver:print('{')
      for i in data do
        if (i~=1) then 
          webserver:print(',')
        end
        webserver:print('"' .. data[i] .. '":')
        s=getfield(data[i])
        if s then
            vartype = type(s)
        if ( vartype =='function' ) or ( vartype =='thread' ) or ( vartype == 'userdata' ) then
                webserver:print('"[' .. vartype .. ']"')
            else 
                if (s==nil) then
                  webserver:print('null')
                else
                  webserver:print(json.encode(s))
                end
            end
        else
            webserver:print('"[Variable Not found]"')
        end
      end
      webserver:print('}')
    end
    
    
            
    %>
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  10. #10
    Join Date
    Jan 1998
    Location
    Jupiter, FL
    Posts
    13,553

    Default

    Try adding

    Code:
    webserver:setHeaderEx("Content-Type", "application/json; charset=ISO-8859-1", true);
    after the initial <%

    Next I'd use FireFox developer console to see exactly what is being transfered (F12 -> Network )
    Ron
    No support through PM

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •