There are lots and lots of characters that can cause problems like this, and you really have no hope of trying to enumerate them all. You should think seriously about translating everything
except a small subset of legal characters to underscores. That way you will catch accented characters, Unicode characters, undesirable sequences of characters such as
.. and
~ and
/, and so on. Something like this would probably do:
$name =~ tr/-A-Za-z0-9/_/c;
I know this doesn't completely answer your question, because you asked how to translate accented characters to their unaccented versions, not how to replace them across the board. The big problem with the de-accenting approach is that there are a huge variety of accented characters you potentially have to deal with. What's more, I believe that the codes used for accented characters (which are not part of standard ASCII) will vary depending on what character set you are actually using.
You didn't say explicitly, but I'm assuming you're creating these Web pages via CGI. Security is something you'll need to approach very seriously if you are doing things like writing files based on user-supplied filenames. You might also want to read up on taint mode and check out Ovid's CGI Course for some further hints.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.