PEAR Manual
Prev |  | Next

# Worksheet::setInputEncoding

Worksheet::setInputEncoding -- Allow writing for different charsets.

## Synopsis

    require_once "Spreadsheet/Excel/Writer.php";

``void Worksheet::setInputEncoding` (string $encoding)`

## Description

It allows writing for different charsets by setting the worksheet's "current" charset. It has been tested for UTF-8, ISO-8859-7. It requires iconv for any charset other than UTF-16LE.

## Parameter

- `string $encoding` - The encoding. It suports all encodings supported by php's iconv() function.

## Note

This function can not be called statically.

## Example

Example 37-1. Using setInputEncoding()
    <?php
    require_once 'Spreadsheet/Excel/Writer.php';
    $workbook = new Spreadsheet_Excel_Writer('test.xls');
    $workbook->setVersion(8);
    $worksheet =& $workbook->addWorksheet('International worksheet');

    $russian = "\xD0\xBF\xD0\xBE\xD0\xBA\xD0\xB0";
    $greek = "\342\345\353\355\341";

    $worksheet->setInputEncoding('ISO-8859-7');
    $worksheet->write(0, 0, $greek);
    $worksheet->setInputEncoding('utf-8');
    $worksheet->write(1, 0, $russian);
    $workbook->close();
    ?>

Prev | Home | Next
Worksheet::getName | Up | Worksheet::select