For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2004 > Converting special characters?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Converting special characters?
Kevin Zembower

2004-09-30, 2:55 am

I've been given the job of writing a CGI script to receive the data from a =
form and append it to a text file. Later, the text file will be analyzed =
using MS Access. My problem is escaping characters which are often used as =
delimiters in text-based importing formats, such as ' or " or \t or \n. =
Any of these could be legitimately entered by a user into the text fields =
of the form. I'd like to capture these, and not just discard them, and in =
such as way that they can be easily converted back into the original =
characters after importing into Access.

Is there a standardized or commonly accepted way of doing this?

I first looked at HTML::Entities, but it doesn't look as if it converts \t =
or \n. Otherwise, this would be a good choice. I also looked at Unicode::St=
rings, but it seemed as if this would convert the entire string to =
Unicode, which I don't know if Access accepts, or if this would even =
solve my problem.

The form is an Adobe .pdf form with editable fields, which returns the =
data as an .fdf file. Don't think this is important, but you can learn =
more about it at http://www.adobe.com/support/techdocs/27f9a.htm.

I tried searching CPAN on 'encoding' but that didn't seem to be the right =
term.

Thanks for your help and advice.

-Kevin


-----
E. Kevin Zembower
Internet Systems Group manager
Johns Hopkins University
Bloomberg School of Public Health
Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD 21202
410-659-6139

Wiggins d Anconia

2004-09-30, 2:55 am

> I've been given the job of writing a CGI script to receive the data
from a form and append it to a text file. Later, the text file will be
analyzed using MS Access. My problem is escaping characters which are
often used as delimiters in text-based importing formats, such as ' or "
or \t or \n. Any of these could be legitimately entered by a user into
the text fields of the form. I'd like to capture these, and not just
discard them, and in such as way that they can be easily converted back
into the original characters after importing into Access.
>
> Is there a standardized or commonly accepted way of doing this?
>
> I first looked at HTML::Entities, but it doesn't look as if it

converts \t or \n. Otherwise, this would be a good choice. I also looked
at Unicode::Strings, but it seemed as if this would convert the entire
string to Unicode, which I don't know if Access accepts, or if this
would even solve my problem.
>
> The form is an Adobe .pdf form with editable fields, which returns the

data as an .fdf file. Don't think this is important, but you can learn
more about it at http://www.adobe.com/support/techdocs/27f9a.htm.
>
> I tried searching CPAN on 'encoding' but that didn't seem to be the

right term.
>
> Thanks for your help and advice.
>
> -Kevin
>


If possible you should consider using a CSV formatting module, this will
translate best into Access (which you should avoid completely if
possible). Text::CSV or even DBI/D::CSV are excellent. These modules
will allow you to setup your delimiters however you wish, and Access
should support importing from them.

helps?

http://danconia.org
Kevin Zembower

2004-09-30, 2:55 am

>>> Wiggins d Anconia <wiggins@danconia.org> 09/29/04 12:08PM >>>
If possible you should consider using a CSV formatting module, this will
translate best into Access (which you should avoid completely if
possible). Text::CSV or even DBI/D::CSV are excellent. These modules
will allow you to setup your delimiters however you wish, and Access
should support importing from them.

helps?

http://danconia.org

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D
Helps very much. Thank you, Wiggins.

-Kevin

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com