in reply to Substr cannot extract last special character

Hi, If i understood your question correctly, here is my coding:

my $ohm = '24Ù'; print "Before substract : $ohm"; if ($ohm =~ /[^!-~\s]/g)#This helps to find the non ascii character { $unit=$&; $ohm=~s/$unit//e; } print "\nUnit : $unit\nAfter substract : $ohm"; # This will return a +? in my CMD be aware that you cannot see the Ohm character

I think it helps you.

Regards,
Velusamy R.

Replies are listed 'Best First'.
Re^2: Substr cannot extract last special character
by Samy_rio (Vicar) on Aug 19, 2005 at 05:59 UTC

    Sorry juo, I misunderstood the question, here is my suggestion:

    my $ohm = '24Ù 34Ã 234Æ 32Ï 23Ð 1½ 23§'; print "Before substract : $ohm\n"; while ($ohm =~ /[^!-~\s]/g)#This helps to find the non ascii character { $unit=$&; $ohm=~s/$unit//e; $foo ='&#x'.sprintf("%04X",ord($unit)).";"; print "Unit : $unit\tHex : $foo\n"; }

    In CMD, display the following hexadecimal values:

    Hex : Ù Hex : Ã Hex : Æ Hex : Ï Hex : Ð Hex : ½ Hex : §

    These hexadecimal values are viewed in IE as HTML and XML file, I am getting exact symbol which are present in the code.

    Please, try this.

    Regards,
    Velusamy R.