# phpman > info > Unicode::String

[String(3pm)](https://www.chedong.com/phpMan.php/man/String/3pm/markdown)           User Contributed Perl Documentation          [String(3pm)](https://www.chedong.com/phpMan.php/man/String/3pm/markdown)

NAME
       [Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown) - String of Unicode characters (UTF-16BE)

SYNOPSIS
        use [Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown) qw(utf8 latin1 utf16be);

        $u = utf8("string");
        $u = latin1("string");
        $u = utf16be("\0s\0t\0r\0i\0n\0g");

        print $u->utf32be;   # 4 byte characters
        print $u->utf16le;   # 2 byte characters + surrogates
        print $u->utf8;      # 1-4 byte characters

DESCRIPTION
       A "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" object represents a sequence of Unicode characters.
       Methods are provided to convert between various external formats
       (encodings) and "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" objects, and methods are provided for
       common string manipulations.

       The functions utf32be(), utf32le(), utf16be(), utf16le(), utf8(),
       utf7(), latin1(), uhex(), uchr() can be imported from the
       "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" module and will work as constructors initializing
       strings of the corresponding encoding.

       The "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" objects overload various operators, which means
       that they in most cases can be treated like plain strings.

       Internally a "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" object is represented by a string of 2
       byte numbers in network byte order (big-endian). This representation is
       not visible by the API provided, but it might be useful to know in
       order to predict the efficiency of the provided methods.

   METHODS
   Class methods
       The following class methods are available:

       [Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)->stringify_as
       [Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)->stringify_as( $enc )
           This method is used to specify which encoding will be used when
           "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" objects are implicitly converted to and from
           plain strings.

           If an argument is provided it sets the current encoding.  The
           argument should have one of the following: "ucs4", "utf32",
           "utf32be", "utf32le", "ucs2", "utf16", "utf16be", "utf16le",
           "utf8", "utf7", "latin1" or "hex".  The default is "utf8".

           The stringify_as() method returns a reference to the current
           encoding function.

       $us = [Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)->new
       $us = [Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)->new( $initial_value )
           This is the object constructor.  Without argument, it creates an
           empty "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" object.  If an $initial_value argument is
           given, it is decoded according to the specified stringify_as()
           encoding, UTF-8 by default.

           In general it is recommended to import and use one of the encoding
           specific constructor functions instead of invoking this method.

   Encoding methods
       These methods get or set the value of the "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)" object by
       passing strings in the corresponding encoding.  If a new value is
       passed as argument it will set the value of the "[Unicode::String](https://www.chedong.com/phpMan.php/perldoc/Unicode%3A%3AString/markdown)", and
       the previous value is returned.  If no argument is passed then the
       current value is returned.

        o<angle>

        <angle>

        o

        o<angle>o

        <*>o<angle><angle>

        <angle>

        <integral>

        <*>

               _
       <*><**>o

       o<angle> <angle>

       o<angle>o<angle> <*> <*>

        <*> o<angle>o

        <*>

       <*> <permille><permille>

        <*> o

       <*>

        <*>

       <*>

        <*>

       <*>

       <*>

        '

       <*>

        <permille><*>

        <permille><*>

       <*>

        <*>

       <*>

       <*><*> <*><*> <*><*> <*><*> <*><*> <*> <*><*> <*><*>

       <*><*> <*><*> <*><*>

       <*><*> <*><*> <*_<permille> <*> <*><*><*><*><*><*><*><*><*><*><*><*>
       <*> <*><*><*><*> <permille> <permille> <*> <*><*>

       <*><*> <*> <*> <*> <*> <*><*>-~ <*><*> <*><*><permille> <*><*> <*><*>
       <*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*><*>
       <*><*><*><*> <*><*> <*> <*> <*><*>

       <*><*>

       <*><*> <*><*> <*><*>

       <*><*> <*><*> <*><*>-~

       <*><*> <*>-~ <*> <*><*> <*><*>

perl v5.34.0                      2022-02-06                       [String(3pm)](https://www.chedong.com/phpMan.php/man/String/3pm/markdown)
