PYTHON is_unicode

is this article helpful?
|
Python replacement for PHP's is_unicode [ edit | history ]
# Python 2.x
isinstance(var, unicode)
# Python 3.x
isinstance(var, str)

PHP is_unicode

PHP original manual for is_unicode [ show | php.net ]

is_unicode

(PHP 6 >= 6.0.0)

is_unicodeFinds whether a variable is a unicode string

Description

bool is_unicode ( mixed $var )

Finds whether the given variable is a unicode string.

Parameters

var

The variable being evaluated.

Return Values

Returns TRUE if var is a unicode string, FALSE otherwise.

Examples

Example #1 is_unicode() example

<?php
// Declare a unicode string
$unicode 'This is a unicode string';

// Declare a binary string
$binary b'This is a binary string';

var_dump(is_unicode($unicode), is_unicode($binary));
?>

The above example will output:

bool(true)
bool(false)

See Also

  • is_binary() - Finds whether a variable is a native binary string
  • is_buffer() - Finds whether a variable is a native unicode or binary string
  • is_string() - Find whether the type of a variable is string
  • unicode_encode() - Convert a unicode string in any encoding