|
Posted by Dr J R Stockton on April 16, 2008, 10:29 am
Please log in for more thread options
> Dr J R Stockton wrote:
>
> > One could easily be written, e.g. by yourself. =A0A TEXTAREA for input,
> > a BUTTON, a TEXTAREA for output, and a series of RegExps, acting on
> > the content of the first area and writing to the second.
>
> If you are going to go that route, write it in Perl and take advantage
> of the HTML::Entities module. No need to write all those regexen.
Then do it yourself <g> .
IMHO, it's much easier to do it in JavaScript, the natural language
for the OP's request of a "site", than it would be to learn Perl. And
it turns out that there's no need to write RegExps as such, if one
provides an input area for the user to define the conversions.
The following includes self-test :
<form class=3DTRY action=3D"#">
<textarea name=3DT0 cols=3D69 rows=3D4>
Replace first field by second field
¿ &#191; Comment follows second TAB
q Q Paste new content into this box
</textarea>
<textarea name=3DT1 cols=3D69 rows=3D4>
Text input
¿que?</textarea>
<br><input type=3Dbutton value=3D"->" onClick=3D"TextConv(this.form)"><br>
<textarea name=3DT2 cols=3D69 rows=3D4></textarea>
</form>
function TextConv(F) { var St, XX, J
XX =3D F.T0.value.split(/[\r\n]+/)
St =3D F.T1.value
for (J=3D0 ; J<XX.length ; J++) {
XX[J] =3D XX[J].split("\t")
if (XX[J].length=3D=3D1) XX[J][1] =3D ""
XX[J][0] =3D new RegExp(XX[J][0], "g") }
for (J=3D0 ; J<XX.length ; J++) St =3D St.replace(XX[J][0], XX[J][1])
F.T2.value =3D St }
I did it in my js-misc1.htm#TS; but I'll not be leaving it there if
signs of excessive use appear - take a COPY. RSVP if bugs are found;
tested in IE7 FF2 Op9 Sf3. FF2 has a mini-bug : the testareas appear
to be 5 rows.
BTW, my newsreader did in fact show the accented =ED, about one pixel
different from a normal one at normal size, but good at 20 pt.
--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/> FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ...
|
|
Posted by Scott Bryce on April 17, 2008, 12:56 am
Please log in for more thread options
Dr J R Stockton wrote:
> IMHO, it's much easier to do it in JavaScript, the natural language
> for the OP's request of a "site", than it would be to learn Perl.
That depends on whether the OP knows JavaScript better than Perl. I know
Perl better than JavaScript.
> And it turns out that there's no need to write RegExps as such, if
> one provides an input area for the user to define the conversions.
Yuck!
So in your solution, the user has to look up the entities himself, and
enter them into a text area, and hope he doesn't make any mistakes.
-------
use strict;
use warnings;
use HTML::Entities;
while(<DATA>)
{
print encode_entities($_);
}
__DATA__
¿Necesita agregar una impresora o copiadora adicional a su forma
personalizada de orden? Presione aquí.
vis-à-vis Beyoncé's naïve papier-mâché résumé
|
|
Posted by Dr J R Stockton on April 17, 2008, 4:07 pm
Please log in for more thread options In comp.infosystems.www.authoring.html message <Zq-dncQBL_P-RZvVnZ2dnUVZ
_gSdnZ2d@comcast.com>, Wed, 16 Apr 2008 22:56:01, Scott Bryce
>Dr J R Stockton wrote:
>> IMHO, it's much easier to do it in JavaScript, the natural language
>>for the OP's request of a "site", than it would be to learn Perl.
>
>That depends on whether the OP knows JavaScript better than Perl. I know
>Perl better than JavaScript.
Therefore we have different limitations, but they are, as far as has
been written here, equal in number.
>> And it turns out that there's no need to write RegExps as such, if
>> one provides an input area for the user to define the conversions.
>
>Yuck!
>
>So in your solution, the user has to look up the entities himself, and
>enter them into a text area, and hope he doesn't make any mistakes.
That is true. But he can use the solution as is, without seeking Perl;
and the content of the area can be copied and pasted for re-use. I've
added a simple test which will verify the entities. Additionally, your
solution does only what was asked for, whereas mine allows more general
substitutions, for which Perl would need more code.
--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.
|
|
Posted by Scott Bryce on April 18, 2008, 9:34 am
Please log in for more thread options Dr J R Stockton wrote:
> That is true. But he can use the solution as is, without seeking
> Perl;
So build the Perl solution into a cgi application. Then only the server
needs Perl. I kept the code simple to demonstrate how simple it is to
encode enities in Perl.
> and the content of the area can be copied and pasted for re-use.
So can any output from a Perl script.
> I've added a simple test which will verify the entities.
Not necessary with the Perl solution.
> Additionally, your solution does only what was asked for,
But it does do what was asked for. Isn't that what it is supposed to do?
Yours only does what was asked for if the user manages to do most of the
work himself by hand.
> whereas mine allows more general substitutions, for which Perl would
> need more code.
Well, yes, but that isn't what the spec called for.
|
|
Posted by Dr J R Stockton on April 18, 2008, 2:19 pm
Please log in for more thread options In comp.infosystems.www.authoring.html message <Lu2dnXOW-9ocPpXVnZ2dnUVZ
_jKdnZ2d@comcast.com>, Fri, 18 Apr 2008 07:34:53, Scott Bryce
>Dr J R Stockton wrote:
>> That is true. But he can use the solution as is, without seeking
>> Perl;
>
>So build the Perl solution into a cgi application. Then only the server
>needs Perl. I kept the code simple to demonstrate how simple it is to
>encode enities in Perl.
You can do that, presumably; my account does not permit it. I have no
need for it myself; I'd use MiniTrue.
>> whereas mine allows more general substitutions, for which Perl would
>> need more code.
>
>Well, yes, but that isn't what the spec called for.
It did not require a lack of other capability, though. I've provided
something that *can* be used, now; you have but written of another
approach.
--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> unsupported.
|
| Similar Threads | Posted | | garbage characters are now on the site, although they weren't there originally | June 5, 2008, 4:16 pm |
| Page wrongly displays in Spanish only once | December 18, 2007, 1:13 pm |
| David Beckham Caught With Spanish Girl | October 9, 2004, 12:40 pm |
| Language codes / tags in Northern Ireland ? | May 18, 2007, 10:01 am |
| Chinese Characters in html (coding on a Mac OS X) | February 13, 2006, 10:48 pm |
| Rendering "special characters" and html validation | February 28, 2005, 3:16 am |
| Translating foreign characters to HTML code | June 25, 2005, 2:35 pm |
| strange html code to set the type of characters | December 7, 2005, 12:10 am |
| Country list with iso1366 codes and local country names | November 8, 2005, 6:51 am |
| Web site design philosophy: .html and . pdf | May 24, 2005, 9:11 pm |
|