decode a string to "Perl's internal form" without Encode module?



Hello,

At first, I'm sorry that I'm not good at English. :-)

There is a string which is encoded with UTF-8, EUC-KR(Korean), EUC-JP,
or any other encoding scheme.

I want to decode it so that it become a string in "Perl's internal
form" (that is, unicode form.. is it so called "utf8"?).

For example,
$octets = "가나"; # 2 Korean characters, sequence of 6 Bytes
according to UTF-8
$string = "\x{AC00}\x{B098}"; # 2 Unicode characters. I want to get
this from $octets

It can be done easily using Encode module:
use Encode qw(decode);

$string = decode("UTF-8", $octets);

My question is, if I don't have Encode module in my server and I have
Text::Iconv module instead, Can I do the same thing using it? If I
can, how?

use Text::Iconv;

$converter = Text::Iconv->new("UTF-8", to-ENCODING);
$string = $converter->convert($octets);

What do I have to write for "to-ENCODING"?

I tried to "UNICODE" but Text::Iconv seemed to regard "UNICODE" as
"UCS-2LE"...

Any advice would be appreciated,

Raymundo at South Korea.

.



Relevant Pages

  • Re: Sending floats over a client-server in Smalltalk
    ... The trick is knowing what to decode them ... Then encode the number in the remaining bytes. ... ByteString>>floatAt: byteIndex ... I could then take a string ...
    (comp.lang.smalltalk)
  • Re: Unicode File Names
    ... file names get reported as byte strings unless they have the UTF-8 ... zipfile module) uniformly use the character string type, ... chosing between ASCII and CP437 has trade-offs. ... not matter (neither ascii nor cp437 can encode, ...
    (comp.lang.python)
  • Re: CCertAdmin.SetCertificateExtension
    ... > You must determine how the extension should be encoded and perform that> encoding prior to setting varExt.bstrVal and calling> SetCertificateExtension -- and you must then specify PROPTYPE_BINARY, ... > http://wp.netscape.com/eng/security/cert-exts.html appears to describe the> expected encoding as IA5 string. ... > You can use CryptEncodeObject to encode IA5 strings. ...
    (microsoft.public.platformsdk.security)
  • Re: high and low bytes of a decimal
    ... If you're trying to fit integers into a bytestream I'm guessing ... you need to encode your integers into a string ... Chances are you're going to want to use big-endian order, ...
    (comp.lang.perl.misc)
  • Re: detecting a UTF-8 string
    ... I want to check if a certain string is UTF-8 or not. ... For example, if I have a UTF-8 encoded file and an ANSI encoded file, if I ... encode a text as UTF-8 twice. ... the middle of a multi-byte character, ...
    (perl.beginners)