Symbian3/PDK/Source/GUID-5373B575-F284-5774-9C73-2A18C4A912A2.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 16 Jul 2010 17:23:46 +0100
changeset 12 80ef3a206772
parent 9 59758314f811
permissions -rw-r--r--
Week 28 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 1897, Bug 344, Bug 2681, Bug 463, Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-5373B575-F284-5774-9C73-2A18C4A912A2"><title>Using Standard Names and MIB enums (SNM) </title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Internet names, standard names and MIB enums (SNM) are widely used for character sets. This section describes how to use these names and values during character conversion. </p> <section id="GUID-E3BEB74D-79C7-59A9-9366-CCD8B52DB7F8-GENID-1-12-1-31-1-1-4-1-5-1-4-1-6-1-2-2"><p>Before you start, you must understand: </p> <ul><li id="GUID-6834352F-169B-55B6-9A25-7E2D2EFB62E4"><p> <xref scope="external" href="http://www.iana.org/assignments/character-sets">Standard names and MIB enums </xref> (SNM) </p> </li> <li id="GUID-44A0D093-E7DE-5A99-9035-E17FCC0B35EB"><p><xref href="GUID-325D8E31-584B-5B10-902C-F004641A614D.dita">Charconv framework conversion APIs</xref>. </p> </li> </ul> </section> <section><title>Introduction</title> <p>To convert text between a foreign encoding and Unicode you must know the UID of the character converter. </p> <p>Device creators can create files which map SNM information of character sets to the UIDs of their character converters. Application developers can then use the MIB enum value or an alias of a character set without knowing its UID. </p> </section> <section><title>Procedure</title> <p> <b>Creating an SNM source file</b>  </p> <p>Device creators can create an SNM mapping file in the ROM as follows: </p> <ol id="GUID-B3316083-E593-5160-919F-98CED9E8AFDD"><li id="GUID-01555850-9692-5FAD-97CF-F4A2E944C6DA"><p>Create an SNM source file using a text editor on a PC and save it. For example d:\charconvfiles\basicsnm.txt. </p> <p>This file must define the mapping between Symbian-specific character set UIDs and one or more standard names and MIB enums. Refer to <xref href="GUID-CD3B2B7D-BAE5-5F99-A5F5-74AFC678D986.dita">SNM Source File Reference</xref> for the file syntax. For information about Symbian UIDs, refer to the <filepath>charconv.h</filepath> header file. </p> <codeblock id="GUID-7F08B7AD-9AFA-5712-9D3D-AF87F5E9C2D8" xml:space="preserve">
...
CharacterSet 0x10004cc6
    StandardName    "US-ASCII"
    StandardName    "ASCII"
    StandardName    "ANSI_X3.4-1968"
    StandardName    "iso-ir-6"
    StandardName    "ANSI_X3.4-1986"
    StandardName    "ISO_646.irv:1991"
    StandardName    "ISO646-US"
    StandardName    "us"
    StandardName    "IBM367"
    StandardName    "cp367"
    StandardName    "csASCII"
    MibEnum            3

CharacterSet 0x10003b10
    StandardName    "ISO-8859-1"
    StandardName    "ISO_8859-1"
    StandardName    "latin1"
    StandardName    "iso-ir-100"
    StandardName    "l1"
    StandardName    "IBM819"
    StandardName    "CP819"
    StandardName    "csISOLatin1"
    MibEnum            4
...
</codeblock> </li> <li id="GUID-65593A6B-21F3-5416-AE81-7D81AB771C95"><p>Use the <codeph>snmtool</codeph> to generate an SNM file from the source SNM file. </p> <p>From a command line, run the following commands to go to the Symbian tools directory and execute <codeph>snmtool</codeph>: </p> <p><userinput>cd d:\Symbian\epoc32\tools</userinput> </p> <p><userinput>snmtool.bat d:\charconvfiles\basicsnm.txt d:\charconvfiles\basic.snm</userinput> </p> </li> <li id="GUID-29001446-1A91-5694-886C-EA57AFEE51EC"><p>Copy the SNM file to the <filepath>\system\charconv\</filepath> directory. </p> </li> </ol> <p> <b>Retrieving a Character Converter UID using an SNM standard name or MIB enum</b>  </p> <ol id="GUID-7A861BDF-B0E8-53F8-B14F-5E69477F79E3"><li id="GUID-0A625B0A-6D8A-5D20-9DB6-E88B7CA83B86"><p>Use an SNM standard name or MIB enum value to retrieve the UID of the character converter. </p> <codeblock id="GUID-A1A41057-D50A-50A5-955E-C59B9B739A5B" xml:space="preserve">RFs fileServerSession;
CCnvCharacterSetConverter* characterSetConverter = CCnvCharacterSetConverter::NewLC();

TUint characterSetUid = 
    characterSetConverter-&gt;ConvertStandardNameOfCharacterSetToIdentifierL(_L8("ASCII"), fileServerSession);

    // use the UID to load the converter.
CCnvCharacterSetConverter::TAvailability available = 
    characterSetConverter-&gt;PrepareToConvertToOrFromL(characterSetUid, fileServerSession);
...</codeblock> </li> </ol> <p>There are two functions for getting a UID: </p> <ul><li id="GUID-B5DC4C12-C0F6-5A66-B4EA-68A154F777FA"><p> <codeph>CCnvCharacterSetConverter::ConvertStandardNameOfCharacterSetToIdentifierL()</codeph> takes a standard name as a parameter. </p> </li> <li id="GUID-E0F345C4-22D9-5090-B4C2-97071EBBB49A"><p> <codeph>CCnvCharacterSetConverter::ConvertMibEnumOfCharacterSetToIdentifierL()</codeph> takes a MIB enum value as a parameter. </p> </li> </ul> <p>These functions read the SNM file to get the UID. The UID can then be passed to <codeph>PrepareToConvertToOrFromL()</codeph> to load the right converter. </p> <p> <b>Note</b>: If there are multiple SNM files, the contents are combined. </p> </section> </conbody></concept>