in reply to Matching/replacing a unicode character only works after decode()

The correct order of operations for working with encoded data (whether utf8 or any other encoding) is:

  1. Input
  2. Decode
  3. Operate
  4. Encode
  5. Output

If you don't decode your input you'll be comparing apples and elephants which is why your regex fails to match. However, if you do no operations on the data at all, then you can skip the middle three steps because your perl script in that case is just essentially a pipe between your input (eg. database) and your output (eg. web page).

This is all explained in much better detail in A UTF8 round trip with MySQL. HTH.

  • Comment on Re: Matching/replacing a unicode character only works after decode()