 
                
        
     
                
        
     
                
        
     
                
        
     
                
        
    charMap = {    
    "unicode" : {
        # Map character mappings.
        WALL_TILE1: u"\u2591", # Light shade.
        WALL_TILE2: u"\u2592", # Medium shade.
        WALL_TILE:  u"\u2593", # Dark shade.
        FLOOR_TILE: u"\xB7",   # Middle dot.
        DOOR_TILE:  u"\u25FC", # Black square.
        CUBE_TILE:  u"\u2588", # Full block.
        CHAR_TILE:  u"@",
        # Line-drawing characters.
        "light-horizontal":         u"\u2500",
        "light-vertical":           u"\u2502",
        "light-down-and-right":     u"\u250C",
        "light-down-and-left":      u"\u2510",
        "light-up-and-right":       u"\u2514",
        "light-up-and-left":        u"\u2518",
        "full-block":               u"\u2588",
        "medium-shade":             u"\u2592",
        "black-square":             u"\u25FC",
        "white-square":             u"\u25FB",
    },
    "html" : {
        # Map character mappings.
        WALL_TILE1: "░",
        WALL_TILE2: "▒",
        WALL_TILE:  "▓",
        FLOOR_TILE: "·",
        DOOR_TILE:  "◼",
        CUBE_TILE:  "█",
        CHAR_TILE:  u"@",
        # Line-drawing characters.
        "light-horizontal":         "─",
        "light-vertical":           "│",
        "light-down-and-right":     "┌", 
        "light-down-and-left":      "┐",
        "light-up-and-right":       "└",
        "light-up-and-left":        "┘", 
        "full-block":               "█",
        "medium-shade":             "▒",
        "black-square":             "◼",
        "white-square":             "◻",
    }
}
        
         
                
        
     
                
        
     
                
        
    
One workaround I had to do, was to send my data as binary frames. If I send them as text frames, I get a browser-side error of "WebSocket connection to 'ws://127.0.0.1:9876/stuff' failed: Could not decode a text frame as UTF-8." and the browser disconnects because of it. This is because of the embedded escape sequences. If I send them as binary frames, it arrives as a blob or an arraybuffer and converting it back to a proper utf-8 string results in the following code being required:
This is of course a giant hack to workaround the presumed inability of javascript to interpret an array of data as a unicode string. Has anyone else had to go through this, and come up with a better solution?
Obligatory screenshot of hack in action:
Has anyone else gotten their web socket implementation working, having dealt with the same problems, and worked out a better way to do it?