We use BLOBS to store XML (and other) data and it would be really useful if DB Explorer could display this information. Currently there is already a "Display as Image..." - maybe a "Display as Text..." could be added? Alternatively, maybe the explorer could auto-detect that the content of a BLOB is all ASCII/UTF-8 and display it this way in the cell.
Autodetecting the "correct" encoding is hard - if not impossible. You can't seperate pure ASCII text from UTF-8 encoded text, that only contains "low range" characters (that map to ASCII). Imaging this:
<?xml version="1.0" charset="ISO-8859-15"?>
That coding does contain the EUR symbol, encoding this as UTF-8 and saving the content to database basicly destroys the document content, as the codepoint that represents EUR in ISO-8859-15 is most probably not the same as in UTF-8 (i did not check).
What is more, you need probably read a lot of the data to guess correctly.
From a quick glance:
Add a menu entry "Open as Text", the associated action then opens the Blob, read the $random_number bytes and does some basic checks:
- Is a BOM present?
- Is an XML declaration contained?
If one of the above is found, make an educated guess for a "default" charset. If none of the above holds true, use the "default" plattform charset as default (or better UTF8???). After that ask the user to choose encoding. An input window like the CLOB case could be used, with an drop down to change the encoding for saving.
This was put down, so that I don't forget it :-)
Created attachment 146726 [details]
proposed patch v1
Attached you can find an implementation of the feature. It is basic, but should do the job. For XML derivatives charset encoding is copied from the XML module.
@NB-Dev: Please review the patch.
Patch applied - http://hg.netbeans.org/core-main/rev/df44f80d9a79
Thanks Matthias for it.
Integrated into 'main-silver', will be available in build *201407190718* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Libor Fischmeistr <email@example.com>
Log: #241490: Provide a way to display ASCII BLOB content