d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Unicode Tables
Add Reply New Topic New Poll
Member
Posts: 7,195
Joined: Nov 23 2006
Gold: 13,386.00
Oct 15 2021 04:49pm
I've been working on creating useful tables to organize information for D2R.

It seems that there would be a way to make a plain text table using Unicode, seeing how it's forced space doesn't get condensed by d2jsp's code like ASCII's does.

Does anybody know of a Unicode table generator out there? I've searched and I can't seem to find one that ALSO uses the Unicode space (U+2800) for spacing.
Member
Posts: 1,894
Joined: Sep 11 2011
Gold: 19,615.00
Oct 15 2021 06:21pm
You can find any plaintext table generator on github and replace the padding character they use. I've done it with this one: https://github.com/ozh/ascii-tables (Go to script.js, and on line 418 replace the space with whatever unicode character you want).
Unfortunately that still won't work, because jsp displays text in regular posts using a variable-width font (as opposed to a monospaced/fixed-width font), which means that you can't easily pad columns by making sure every column has the same number of characters (which is what plaintext table generators do).
The simple solution is to use the code tag which renders text in a monospaced font, but of course bbcode won't work inside (although you wouldn't need to bother with unicode spaces then).
You might be able to measure the string width in actual pixels using the canvas https://stackoverflow.com/a/21015393/4500419 and use that to pad columns to the appropriate size, but it'd be super hacky and probably wouldn't work that great, would have lots of bugs depending on the browser used, if the user has a custom stylesheet applied on top, etc.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll