Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-137

bsondump in Windows doesn't display UTF-8 right



    • Investigation
    • Status: Accepted
    • Minor - P4
    • Resolution: Unresolved
    • None
    • None
    • bsondump
    • Windows


      When bsondump is displaying UTF-8 strings in json mode (the default), it just sends the UTF-8 text to the display as-is (except for some escaping of certain characters). In Windows, 8-bit characters sent to the screen are displayed according to the current code page. In American installs of Windows, this is likely to be code page 437, the DOS code page (remember DOS?) and so you get line drawing characters and some Greek instead of the intended characters when non-ASCII Unicode characters are in the string. In Europe, the code page is likely to be code page 1252 ("Windows ANSI") which is pretty much ISO Latin-1 so the UTF-8 component bytes will show up as assorted European characters – not the intended ones.

      This turns out to be fairly easy to fix by switching the console's code page to CP_UTF8 before entering the display code and restoring it to whatever it was before exiting. In the UTF-8 code page, we can treat the console as if it was Linux and it will work for any characters supported by the font.




            backlog-server-tools Backlog - Server Tools Team
            tad Tad Marshall
            0 Vote for this issue
            1 Start watching this issue