Texinfo::Convert::Unicode
*************************

NAME
====

Texinfo::Convert::Unicode - Handle conversion to Unicode

SYNOPSIS
========

  use Texinfo::Convert::Unicode qw(unicode_accent encoded_accents
                                   unicode_text);

  my ($innermost_contents, $stack)
      = Texinfo::Common::find_innermost_accent_contents($accent);

  my $formatted_accents = encoded_accents ($converter,
                        convert($innermost_contents), $stack, $encoding,
                        \&Texinfo::Text::ascii_accent_fallback);

  my $accent_text = unicode_accent('e', $accent_command);

DESCRIPTION
===========

Texinfo::Convert::Unicode provides methods that deals with unicode for converters. Unicode is important, because it is used internally in perl for strings, therefore if converted to Unicode, a string could be output in other encodings as well when writting out the converted documents.

When an encoding is given as argument of a method of the module, the accented letters should only be converted to unicode if it is known that it will be possible to convert the unicode points to encoded charactes in the encoding character set.

METHODS
=======

$result = unicode_accent($text, $accent_command)

     $text is the text appearing within an accent command.  $accent_command should be a Texinfo tree element corresponding to an accent command taking an argument.  The function returns the unicode representation of the accented character.

$result = encoded_accents ($converter, $text, $stack, $encoding, $format_accent, $set_case)

     $converter is a converter object.  It may be undef if there is no need of converter object in $format_accent ($format_accent described below). $text is the text appearing within nested accent commands.  $stack is an array reference holding the nested accents texinfo element trees.  For example, $text could be the formatted content and $stack the stack returned by Texinfo::Common::find_innermost_accent_contents.  $encoding is the encoding the accented characters should be encoded to.  If $encoding not set the $result is set to undef.  $format_accent is a function reference that is used to format the accent commands if there is no encoded character available for the encoding $encoding at some point of the conversion of the $stack.  Last, if $set_case is positive, the result is upper-cased, while if it is negative, the result is lower-cased.

$result = unicode_text ($text, $in_code)

     Return $text with characters encoded in unicode.  If $in_code is set, the text is considered to be in code style.

$result = unicode_for_brace_no_arg_command($command_name, $encoding)

     Return the unicode representing a command with brace and no argument $command_name (like @bullet{}, @aa{} or @guilsinglleft{}), or undef if there is no available encoded character for encoding $encoding.

$width = string_width($string)

     Return the string width, taking into account the fact that some characters have a zero width (like composing accents) while some have a width of 2 (most chinese characters, for example).

AUTHOR
======

Patrice Dumas, <pertusus@free.fr>

COPYRIGHT AND LICENSE
=====================

Copyright 2010, 2011, 2012 Free Software Foundation, Inc.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.