473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Is it simple to use LineDraw characters in <PRE> mode?

I'm getting ready to revamp my Magic Squares pages, which currently
show the magic squares in this form:

+---+---+---+---+---+---+---+---+---+---+---+
| 68| 81| 94|107|120| 1 | 14| 27| 40| 53| 66|
+---+---+---+---+---+---+---+---+---+---+---+
| 80| 93|106|119| 11| 13| 26| 39| 52| 65| 67|
+---+---+---+---+---+---+---+---+---+---+---+
| 92|105|118| 10| 12| 25| 38| 51| 64| 77| 79|
+---+---+---+---+---+---+---+---+---+---+---+
|104|117| 9 | 22| 24| 37| 50| 63| 76| 78| 91|
+---+---+---+---+---+---+---+---+---+---+---+
|116| 8 | 21| 23| 36| 49| 62| 75| 88| 90|103|
+---+---+---+---+---+---+---+---+---+---+---+
| 7 | 20| 33| 35| 48| 61| 74| 87| 89|102|115|
+---+---+---+---+---+---+---+---+---+---+---+
| 19| 32| 34| 47| 60| 73| 86| 99|101|114| 6 |
+---+---+---+---+---+---+---+---+---+---+---+
| 31| 44| 46| 59| 72| 85| 98|100|113| 5 | 18|
+---+---+---+---+---+---+---+---+---+---+---+
| 43| 45| 58| 71| 84| 97|110|112| 4 | 17| 30|
+---+---+---+---+---+---+---+---+---+---+---+
| 55| 57| 70| 83| 96|109|111| 3 | 16| 29| 42|
+---+---+---+---+---+---+---+---+---+---+---+
| 56| 69| 82| 95|108|121| 2 | 15| 28| 41| 54|
+---+---+---+---+---+---+---+---+---+---+---+

Would it be possible for me to use the equivalent of the MS LineDraw
characters so that the lines would be solid and the corners would look
like corners?

Ideally, I'd like to do the entire magic square in one font, with one
character per position. Trying to use five characters to spell out an &
code each time would increase the size of the page too much.

Thanks for any help.

John

Aug 14 '05 #1
18 2228
On 13 Aug 2005 18:21:47 -0700, "John" <Go******************@gmail.com>
wrote:
Would it be possible for me to use the equivalent of the MS LineDraw
characters so that the lines would be solid and the corners would look
like corners?


Why not use a table?
Aug 14 '05 #2
I thought about that, but by the time I get to a 31x31 magic square or
a 49x49 magic square, I'm thinking that the overhead of all the table
cells will increase the size of the html tremendously.

A 31x31 table would add [TD] and [/TD] 961 times and [TR] and [/TR] 31
times. That's 9K larger, not counting the extra characters to center
the text, etc.

That's why I'd love to experiment with the linedraw characters if it's
workable.

But I might decide to try it with tables just to see how it looks. I
guess I still have this dialup mentality (I'm in rural Arkansas, so I'm
in the minority still using dialup because broadband in not available
here yet, even if we're in the same county as WalMart HQ.

John

Aug 14 '05 #3
On 13 Aug 2005 21:32:10 -0700, "John" <Go******************@gmail.com> wrote:
I thought about that, but by the time I get to a 31x31 magic square or
a 49x49 magic square, I'm thinking that the overhead of all the table
cells will increase the size of the html tremendously.

A 31x31 table would add [TD] and [/TD] 961 times and [TR] and [/TR] 31
times. That's 9K larger, not counting the extra characters to center
the text, etc.

That's why I'd love to experiment with the linedraw characters if it's
workable.
Don't think you can do that, use line draw characters, Seagate do,
visit their site and see what they tell you, user needs to download
and install a font.
But I might decide to try it with tables just to see how it looks. I


You can do it with tables, perhaps try generate table code in
javascript if the download time bother you. You probably use
some sort of script to make the table now?

A more modern approach would be to use CSS, dunno if MSIE would
cooperate with you on that one though.

I'm lazy, used <pre> and |-+ charset :) Gives me lynx readable table:

http://bugsplatter.mine.nu/test/linux-2.4/

Cheers,
Grant.

Aug 14 '05 #4
Tim
On Sat, 13 Aug 2005 18:21:47 -0700, John sent:
Would it be possible for me to use the equivalent of the MS LineDraw
characters so that the lines would be solid and the corners would look
like corners?


No, not really. Because you're most likely going to try that by abusing
fonts (using some replacement image instead of the normal glyph for a
character), and that's not how HTML works. Sure you might fluke it for
other Windows users with the same font installed as what you edited with,
but it wouldn't work for everyone else (they'd see garbage where you'd
using the drawing characters).

Unicode has some drawing characters in it, but then there's probably few
people with systems that can make use of them.

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please destroy some files yourself.

Aug 14 '05 #5
On Sun, 14 Aug 2005, Thomas Jespersen seems to have started a thread
by quoting:
On 13 Aug 2005 18:21:47 -0700, "John" <Go******************@gmail.com>
wrote:
Would it be possible for me to use the equivalent of the MS LineDraw
characters
Do you mean the unicode box-drawing characters in the U+25xx range ?
(they can be seen in the official character charts at the Unicode web
site; or there's my own aide-memoire pages - in this case see
http://ppewww.ph.gla.ac.uk/~flavell/...unidata25.html with the
covering notes at http://ppewww.ph.gla.ac.uk/~flavell/unicode/ )
so that the lines would be solid and the corners would look
like corners?


That's what they're evidently meant for. If the boxing characters are
intended as part of the substantive content, then I reckon they're OK.
For example these characters get used by some software which uses HTML
as best it can to express mathematical equations. Case in point,
these characters are used by Ian Hutchinson's ingenious "tth" (tex to
HTML) converter, when tth is used in its more-modern unicode mode
(don't be misled by its old "symbol fonts" mode - that was a kludge
which is best avoided, particularly with modern browsers).

ref: http://hutchinson.belmont.ma.us/tth/manual/sec12.html

The consequences for accessibility e.g speaking browsers should not
need to be spelled out! If you're only looking to decorate some
content with some optional outlines for the visual presentation, it
would be more proper to use CSS to define borders etc. with the
appropriate appearance.

best regards
Aug 14 '05 #6

[subsequent to my previous f'up on this thread, our news server now
seems to have the posting which really did start the thread]

On Sun, 13 Aug 2005, John wrote:
I'm getting ready to revamp my Magic Squares pages, which currently
show the magic squares in this form:

+---+---+---+---+---+---+---+---+---+---+---+
| 68| 81| 94|107|120| 1 | 14| 27| 40| 53| 66|
+---+---+---+---+---+---+---+---+---+---+---+
| 80| 93|106|119| 11| 13| 26| 39| 52| 65| 67|
[...]

I'd rate this as tabular data, and should be marked-up as a table.
Would it be possible for me to use the equivalent of the MS LineDraw
characters so that the lines would be solid and the corners would
look like corners?


As I said in the earlier f'up, there are situations where use of the
unicode box drawing characters could be defensible. But for this
purpose, I'd say it would be inappropriate.
Aug 14 '05 #7
John wrote:
I thought about that, but by the time I get to a 31x31 magic square or
a 49x49 magic square, I'm thinking that the overhead of all the table
cells will increase the size of the html tremendously.

A 31x31 table would add [TD] and [/TD] 961 times and [TR] and [/TR] 31
times. That's 9K larger, not counting the extra characters to center
the text, etc.
That's not a great deal on the web today. Bear in mind that it's very
repetitive, so compressing the pages should reduce each </td><td> to
probably one byte.
That's why I'd love to experiment with the linedraw characters if it's
workable.


Ugh.

--
Nick Kew
Aug 14 '05 #8
I realized after I sent my second message on the subject that I forgot
that I'd also be saving some for all the line symbols I wouldn't be
sending, especially the entire line of symbols between each line, so
it's not quite as bad as I thought.

For a 25x25 magic square, using TABLE only added 3-4 K to the file
size, so I think I'll just go with the TABLE codes.

The 99x99 magic square file ended up an "almost gross" number, almost
144K in size. I decided to stop at 99, since it's already much bigger
than anybody could possibly print, or want to??? You can see the new
pages at the old address: http://www.mazes.com/magic-squares

I'm still curious about the line draw characters, but it's not as
critical now. It might be fun to use them in other kinds of pages.

John

Aug 14 '05 #9
John wrote:
I realized after I sent my second message on the subject that I forgot
that I'd also be saving some for all the line symbols I wouldn't be
sending, especially the entire line of symbols between each line, so
it's not quite as bad as I thought.

For a 25x25 magic square, using TABLE only added 3-4 K to the file
size, so I think I'll just go with the TABLE codes.

The 99x99 magic square file ended up an "almost gross" number, almost
144K in size. I decided to stop at 99, since it's already much bigger
than anybody could possibly print, or want to??? You can see the new
pages at the old address: http://www.mazes.com/magic-squares

I'm still curious about the line draw characters, but it's not as
critical now. It might be fun to use them in other kinds of pages.

John


Here's a simple script that will generate your square, just style it
using CSS or whatever. A page containing a 100x100 square is about 2k.

Just replace the comma separated values with whatever you want.
<style type="text/css">
table { border-collapse: collapse;}
td {text-align: center; border: 1px solid red;}
</style>

....

<script type="text/javascript">

// Replace the following values with whatever
var nums = [
68,81,94,107,120,1,14,27,40,53,66,80,93,106,119,11 ,13,26,39,52,65,
67,92,105,118,10,12,25,38,51,64,77,79,104,117,9,22 ,24,37,50,63,76,
78,91,116,8,21,23,36,49,62,75,88,90,103,7,20,33,35 ,48,61,74,87,89,
102,115,19,32,34,47,60,73,86,99,101,114,6,31,44,46 ,59,72,85,98,
100,113,5,18,43,45,58,71,84,97,110,112,4,17,30,55, 57,70,83,96,109,
111,3,16,29,42,56,69,82,95,108,121,2,15,28,41,54
];

var i, j, m = Math.sqrt(nums.length);
var c=0;
var txt = ['<table>'];
document.write('<table>');
for ( i=0; i<m; i++){
txt.push('<tr>');
for ( j=0; j<m; j++ ){
txt.push('<td>' + nums[c++] + '</td>');
}
txt.push('</tr>');
}
txt.push('</table>');
document.write(txt.join(''));

</script>


--
Rob
Aug 15 '05 #10
Thank you, Alan, the box-drawing characters at
http://ppewww.ph.gla.ac.uk/~flavell/...unidata25.html were exactly
what I was looking for.

Don't know if this will show up right, but here's a rough idea of how
you helped me:
<PRE>
┌---┬---┬---┐
| | | |
├---┼---┼---┤
| | | |
├---┼---┼---┤
| | | |
└---┴---┴---┘
</pre>

Thanks for the help. I may only use it in a few experiments, as I've
already done the main content with tables, or I may use it for a few
worksheets, where accessibility is not a problem.

John

Aug 15 '05 #11
Thanks, RobG,

That looks interesting. I really need to learn javascript sometime.
Looking at your sample made me realize how much i don't know.

But I knew enough to wonder if you might not have given me the line of
code that tells the script that the square is 11 wide. I don't see it.
Is that possibly in the statement that calls the function? (if that's
what this is called).

If you have a recommendation for a free site to help me learn more on
this subject, I'd love to hear about it, especially if you think an old
fogie like me could understand it (my first personal computer was a
TRS-80 Level One in 1977, and my first programming was on a mainframe
in 1969, to give you an idea how far back I go.

John

P.S. My sample didn't show up in the other message, but it's a workable
solution for one of my distant ideas.

Aug 15 '05 #12
John wrote:
Thanks, RobG,

That looks interesting. I really need to learn javascript sometime.
Looking at your sample made me realize how much i don't know.

But I knew enough to wonder if you might not have given me the line of
code that tells the script that the square is 11 wide. I don't see it.
Is that possibly in the statement that calls the function? (if that's
what this is called).
This declares an array of values:

var nums = [
68,81,94,...
];

And this decides the size of the table - it assumes the array contains
the correct number of values for a square matrix, that is, that the
length of the array is a square number):

var i, j, m = Math.sqrt(nums.length);

i and j are declared as undefined variables (they are given values
later), m is given the value of the square root of the length of the
array 'nums'.

If you have a recommendation for a free site to help me learn more on
this subject, I'd love to hear about it, especially if you think an old
fogie like me could understand it (my first personal computer was a
TRS-80 Level One in 1977, and my first programming was on a mainframe
in 1969, to give you an idea how far back I go.


Start here (there's an awful lot of stuff if you follow the links):
<URL:http://www.jibbering.com/faq/>

Some others:
<URL:http://www.crockford.com/javascript/>
<URL:http://www.quirksmode.org/>

A couple of tutorial sites - beware, they are introductory only and are
not always consistent with 'best practice'. Visit/use
comp.lang.javascript frequently.

<URL:http://www.w3schools.com/js/default.asp>

<URL:http://www.sislands.com/javascript/toc.htm>

[...]
--
Rob
Aug 15 '05 #13
RobG wrote:
Here's a simple script that will generate your square, just style it
using CSS or whatever.


And then, a visitor without JavaScript support will arrive.
Aug 15 '05 #14
John wrote:
I thought about that, but by the time I get to a 31x31 magic square or
a 49x49 magic square, I'm thinking that the overhead of all the table
cells will increase the size of the html tremendously.

A 31x31 table would add [TD] and [/TD] 961 times and [TR] and [/TR] 31
times. That's 9K larger, not counting the extra characters to center
the text, etc.


Well, if you're really concerned about the file size and you're using
HTML4, you can omit the end tags for the tr and td elements like this:

<table>
<tr><td>1<td>2<td>3
<tr><td>4<td>5<td>6
<tr><td>7<td>8<td>9
</table>

In bytes, for a 31x31 table, that works out as:
total <td> = 31 × 31 × 4 = 3,844
total <tr> = 31 × 4 = 124
total <table> = 15

total = 3,983

4kB isn't much, especially if it's compressed before sending over the
wire. Also, you need to consider that the number of characters you'd
use by drawing the boxes with box drawing characters would be very close
to that used by the table markup, so it's really not worth choosing a
less accessible method over a semantically/structurally correct table
markup.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Aug 15 '05 #15
JRS: In article <11**********************@z14g2000cwz.googlegroups .com>
, dated Sat, 13 Aug 2005 18:21:47, seen in news:comp.infosystems.www.aut
horing.html, John <Go******************@gmail.com> posted :
I'm getting ready to revamp my Magic Squares pages, which currently
show the magic squares in this form: Would it be possible for me to use the equivalent of the MS LineDraw
characters so that the lines would be solid and the corners would look
like corners?


If you are prepared to use javascript, you only need to send for each
new square a literal array of arrays of numbers, to be expanded by
script : for a non-magic 3*3 example

var AAN = [[1,2,3],[4,5,6],[7,8,9]]

If the script is an include.js file, it only needs to be sent with the
first magic square. The script could use line-draw characters if
available, or + - |, or a Table.

One might use, for a starting-point,

var L = AAN.length
document.write("<table border=1>")
for (y=0 ; y<L ; y++) {
P = AAN[y]
document.write("<tr>")
for (x=0 ; x<L ; x++) document.write("<td>", P[x], "<\/td>")
document.write("<\/tr>") }
document.write("<\/table>")

which works with the above data and should work with any size that the
browser can handle. Code for other boxing would be longer.

I do not know whether the picture can be drawn as a 2D array of div
styles by CSS or otherwise; but I'd expect it to look better that way.

Tests show that it can and does; converting this script method to be
written by javascript as above is left as an exercise, as is checking
that all is valid and works in other browsers :-

<style type="text/css"><!-
.X { font-family: sans-serif ; border: 1px solid black ;
width: 2.5em; height: 2.5em; float: left ;
text-align: center; padding-top: 1ex ; }
.Y { border: 1px solid black ; width: 1em }
--></style>

<div class=Y>

<div class=X>1</div>
<div class=X>22</div>
<div class=X>333</div>
<div class=X>4</div>
<br clear=all>
<div class=X>5</div>
<div class=X>6</div>
<div class=X>7</div>
<div class=X>8</div>

</div>

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 15 '05 #16
> Well, if you're really concerned about the file size and you're using
HTML4, you can omit the end tags for the tr and td elements like this:

<table>
<tr><td>1<td>2<td>3
<tr><td>4<td>5<td>6
<tr><td>7<td>8<td>9
</table>


Hi, Lachlan,

Is this for any browser, or just for some browsers. If it would mess up
some visitors, I certainly wouldn't want to use the trick to save code.

As you might guess, I've been trying to avoid doing something that
would affect people who don't have certain browsers or add-ons. That's
sort of why I haven't gotten into javascript, because back when I first
started reading about it, many people wouldn't have been able to view
stuff in javascript.

So, I've been concentrating on what I assume to be standard html,
though I've done some stuff in ASP because that is only dependent on
the server's system (if I understand it correctly).

John

Aug 15 '05 #17
John wrote:
I thought about that, but by the time I get to a 31x31 magic square or
a 49x49 magic square, I'm thinking that the overhead of all the table
cells will increase the size of the html tremendously.

A 31x31 table would add [TD] and [/TD] 961 times and [TR] and [/TR] 31
times. That's 9K larger, not counting the extra characters to center
the text, etc.
HTML allows you to omit the closing </TR> and </TD>, so you can halve that
estimate. And you need nothing to center the content if you use a CSS style
file which says td {text-align:center}
That's why I'd love to experiment with the linedraw characters if it's
workable.
It's not, and I have extreme difficulty in imagining why you would want to
do something like that in the first place.
But I might decide to try it with tables just to see how it looks. I
guess I still have this dialup mentality (I'm in rural Arkansas, so I'm
in the minority still using dialup because broadband in not available
here yet, even if we're in the same county as WalMart HQ.


Even at the marginal 32Kb/s (which is all I used to get off my nominal
56KB/s dialup connection) I really can't see a page with a 32x32 table
taking more than a second or two to load. Really.

I took your example and tripled it in both directions, and marked it up
as a table. See it at http://research.silmaril.ie/magicsquaretest.html
The HTML file is 7k and the CSS is 26 bytes. Allowing for overhead and
latency, it should still take less than a second to load, but I'd be very
interested to know an exact figure.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
Aug 15 '05 #18
"John" <Go******************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I'm getting ready to revamp my Magic Squares pages, which currently
show the magic squares in this form:

+---+---+---+---+---+---+---+---+---+---+---+
| 68| 81| 94|107|120| 1 | 14| 27| 40| 53| 66|
+---+---+---+---+---+---+---+---+---+---+---+ <snip>
Would it be possible for me to use the equivalent of the MS LineDraw
characters so that the lines would be solid and the corners would look
like corners?


Possible but very clumsy and relies on a visitor to your site having and
using the line-drawing font you specify.

Using tables doesn't add a lot of extra code when compared to a plain text
grid, not if written properly.

Styling a table is very easy and takes just a few lines of code but styling
a plain text grid would be a horrendous mess of <span> and/or <div> tags and
would add far more overhead than a neatly styled table.
Aug 16 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt Adams | last post by:
I want to move the following <PRE> defintion to a css file: <TABLE><TR><TD><PRE>sample text</PRE></TD> <TD> not predefined font</TD></TR></TABLE> should be <TABLE><TR><TD class=aaa>sample...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
10
by: Xah Lee | last post by:
there's a HTML odditity. That is, line break will be ignored inside <preif the adjacent lines are tags. see the source code and description here: http://xahlee.org/js/linebreak_after_tag.html...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.