use Encode qw( decode encode );
... input ...
foreach ($hardwareValue1, $hardwareValue2) {
$_ = decode('UTF-8', $_);
}
... do some work ...
foreach ($hardwareValue1, $hardwareValue2) {
$_ = encode('iso-latin-1', $_);
}
... output ...
If you just want to translate,
use Encode qw( from_to );
... input ...
foreach ($hardwareValue1, $hardwareValue2) {
$_ = from_to($_, 'UTF-8', 'iso-latin-1');
}
... output ...
If a given char doesn't exist in iso-latin-1, you'll get a ? instead.
Remember, when you read in something, it is encoded. Convert it to characters before working on it. When you need to write something, it needs to be encoded.
|