Given that an essential part of your program is your chars.txt file, that would be helpful to post, particularly as I execute your code as posted and do not get that error.
I also note from your output formatting that at the least you have some newlines and spaces in your file that are not accounted for in your code. What happens when you substitute the following into your code?
sub fix_special_characters { my($string) = @_; open(C,"<:utf8","chars.txt"); my @c = <C>; chomp @c; for my $i (0 .. $#c) { my ($special, $htmlchar) = split /\s+/, $c[$i]; print "$special : $htmlchar\n"; $string =~ s/$special/$htmlchar/ig; ## this is generating +the error message } return $string; }
Note I also swapped away from you C-style for loop: why this is a good idea is discussed in 723825. As well, it's a good idea to use strict; use warnings to avoid needless headaches.
In reply to Re: utf-8 problem
by kennethk
in thread utf-8 problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |