Wednesday 15 January 2014

string - How can I make sure I convert to a single encoding regardless of what type I actually have? -


If I get a string inside a Pearl method, I do not know at that point if it is a specific encoding Or do not want to convert it to a specific encoding, how do I do it?
Examples can be some examples (for example, UTF-8 instead of ISO 885 9):

  sub-joke {my $ arg = @_; If ($ arg is not ISO8859) {$ arg = encode :: encode ("ISO-8859", $ arg); } #Usages $ arg}   

Update:
Is the following true? (It is intended that what is $ arg , I have made this method as utf8 and after that I will assign it to code iso8859 And get a representation regardless of the input).

  $ arg = encode :: decode ("utf8", $ arg); $ Arg = encode :: encode ("iso-8859-1, $ args);   

It looks like what I need is covered < P>

what is 80 â? ¬ or Ð ??? Is this text too?

You have to decode the input to do anything to them, and you have to know the encoding of the input to decode it.


I do not know at that point if it is a Whether the encoding is specific or not and to convert it to a specific encoding i How do I?

Normally, you can not. How do you decode decode it, if you do not know what it is?

The best you can use the Hurricistics. The more you know about the input, the better the uplift you can use. For example, if you know that the string is UTF- 8 or ISO-8859-1, you are almost completely guessed Es of which it is. In fact, you can also figure out a file that is a mixture of both!

Is the following true? (What is the purpose of this is that, what is the way of $ AG that I make it in UTF8 and then I write it in ION8859 as an indicative and gets the same representation regardless of input)

No. Those two rows should be encoded using UTF-8. You can not decode without knowing the encoding which it was used to use in symbolic terms.

No comments:

Post a Comment