Re: how to remove c++ comments from a cpp file?
- From: "Gabriel Genellina" <gagsl-py@xxxxxxxxxxxx>
- Date: Fri, 26 Jan 2007 15:56:17 -0300
"Peter Otten" <__peter__@xxxxxx> escribió en el mensaje news:epd751$518$03$1@xxxxxxxxxxxxxxxxxxxx
Laurent Rahuel wrote:
And using the codecs module
Why would you de/encode at all?
I'd say the otherwise: why not? This is the recommended practice: decode inputs as soon as possible, work on Unicode, encode only when you write the output.
In this particular case, it's not necesary and you get the same results, only because these two conditions are met:
- the encoding used is utf-8
- we're looking for '//', and no unicode character contains '/' in its representation using that encoding apart from '/' itself
Looking for the byte sequence '//' into data encoded with a different encoding (like utf-16 or ucs-2) could give false positives. And looking for other things (like '¡¡') on utf-8 could give false positives too.
The same applies if one wants to skip string literals looking for '"' and '\\"'.
Anyway for a toy script like this, perhaps it does not make any sense at all - but one should be aware of the potential problems.
--
Gabriel Genellina
.
- References:
- how to remove c++ comments from a cpp file?
- From: Frank Potter
- Re: how to remove c++ comments from a cpp file?
- From: Gary Herron
- Re: how to remove c++ comments from a cpp file?
- From: Frank Potter
- Re: how to remove c++ comments from a cpp file?
- From: Gabriel Genellina
- Re: how to remove c++ comments from a cpp file?
- From: Laurent Rahuel
- Re: how to remove c++ comments from a cpp file?
- From: Peter Otten
- how to remove c++ comments from a cpp file?
- Prev by Date: Re: Handling empty form fields in CGI
- Next by Date: Re: Help extracting info from HTML source ..
- Previous by thread: Re: how to remove c++ comments from a cpp file?
- Next by thread: Re: how to remove c++ comments from a cpp file?
- Index(es):
Relevant Pages
|
Loading