小糊涂学symbian日记(12)(转)

[Character Conversion Overview]
Converts text between Unicode and other character sets, and between 16-bit Unicode and the Unicode transformation formats UTF-7 and UTF-8. The API can be used to provide a list of all of the foreign character sets available on the device, to select a specific character set to convert to or from, then to do the conversion.

The Character Conversion Plug-In Provider API can be used to write plug-in DLLs. These extend the range of foreign character sets available for conversion beyond the ones already provided by the device.

这组API有两个重要组成:Unicode/non-Unicode转换和Unicode format conversion.

[Introduction to Character Conversion]
在symbian platform中使用的是Unicode字符集,但是要和很多非此字符集的外部程序交互的话,我们就需要字符的转换了。

[Character sets and Unicode]
文本数据在电子设备中是以一定字符集的形式存储的,一个字符集是一个组字符组成的,其中每个都被编码成不同的数字。每个字符的外观并不是字符集的属性,是属于字体范畴的。因此一个字符可能呈现出多种外形,但它们都有个唯一的数字编码。

字符集中,一般西方字符是8-bit编码的情况,而东方字符一般是双字节的,ie16-bit的编码,在Unicode中,给个字符都是被编码为双字节的,有些列外可能编码为四字节。

[Character conversion to and from Unicode]
CCnvCharacterSetConverter类用来在Unicode(UCS-2)和其他字符集之间做转变,一般用16-bit的descriptor表示在UCS-2中的字符,用8-bit的descriptors来表示其他字符集编码。

The first stage of the conversion is to define the non-Unicode character set to be converted to or from, and the second is to convert the text. Selecting the character set to be converted to or from is done using one of the overloads of PrepareToConvertToOrFromL(). Text conversion itself is done using one of the overloads of ConvertFromUnicode() or ConvertToUnicode().

The conversion functions allow piece-by-piece conversion of input strings. Callers do not have to try to guess how big to make the output descriptor for a given input descriptor; they can simply do the conversion in a loop using a small output descriptor. The ability to cope with an input descriptor being truncated is useful if the caller cannot guarantee whether

the input descriptor will be complete, e.g. if they themselves are receiving it in chunks from an external source.

没有直接的办法可以转换两个非unicode字符集,如果要这样做那就分两步好了convert from one character set to Unicode and then from Unicode to another character set.

[Transformation formats]
Unicode字符集中的UCS-2格式将每个字符编码为2个字节。
While this is not important within a system, it does mean that text encoded as UCS-2 cannot easily be shared between systems using a different endian-ness. To overcome this problem the Unicode Consortium has defined two transformation formats for sharing Unicode text. The transformation formats explicitly specify byte order, and cannot be misinterpreted by computers using a different byte order.

于是有了两种不同的格式:UTF-7和UTF-8
*UTF-7:
UTF-7允许Unicode字符集被编码和转换为8-bit的字节,但只有7个bit被使用,UTF-7被分为三个不同的字集,它们分别被不同的编码和定义,如下
1、D集,做为一个单独的字节来编码的,它包括大小写的A到Z,数字和9个其他字符。
2、O集,包括字符! " # $ % & * ; < = > @ [ ] ^ _ { | },这些也都被做个一个单个字节被编码,or with the modified base 64 encoding used for set B characters, When encoded as a single byte, set O characters can be misinterpreted by some applications — encoding as modified base 64 overcomes this problem.
3、Set B comprises the remaining characters, which are encoded as an escape byte followed by 2 or 3 bytes. The encoding format is a modified form of base 64 encoding.

*UTF-8
UTF-8 encodes and transmits Unicode characters as a string of 8-bit bytes. All the ASCII characters 0 to 127 are encoded without change

[Conversion to and from Unicode transformation formats]
有个单独的类CnvUtfConverter,用来转换文本,在Unicode(UCS-2)和两个Unicode变化格式UTF-7和UTF-8之间。它有四个静态成员函数,分别是,ConvertFromUnicodeToUtf7(),ConvertFromUnicodeToUtf8(),ConvertToUnicodeFromUtf7()和ConvertToUnicodeFromUtf8()。

There is no direct way to convert between UTF-7 and UTF-8. Though it is possible to convert from one transformation format to UCS-2 and then from UCS-2 to the other transformation format.

<>
[Design and implementation of STDLIB]
这里描述了symbian软件平台中C标准库的主要特性(一般就是纸STDLIB)。但并不试图给出库的完整API,如果你需要获得ANSI C和POSIX的所有文档,查看下列相关组织地址:http://www.ansi.org和http://standards.ieee.org/index.html

[Porting Guide]
*Overview
这里讲述了如果将一段传统的C代码移植到symbianOS上。我们使用了三个列子:Hello, ConsoleApp和GUIApp。头两个是基于简单控制台的。The third is a command-line driven program which has been converted into a standard symbian application. It demonstrates how to link STDLIB into a C++ project. 它也显示了在转换C代码到symbian OS中可能会遇到的几个问题,包括在DLL中写入数据的限制。这些列子代码都可以在epoc32exstdlib表现出来。

*Installing STDLIB on the target machine
如果需要的话,可以使用stdlib.sis安装STDLIB在目标机器上,在epoc32 eleasewinsudeb and epoc32 eleasewinsurel都有,使用这个sis安装文件有以下的好处:
the DLL is installed in the correct location

the correct version of the DLL is installed

if you supply a .sis file to install your product, STDLIB can easily be included as a sub-component of it

*Hello World—A minimal console application
这里只有个最简单的main()调用标准库的printf()函数。
这里列子的工程项目文件(Hello.mmp)包括如下的内容:
TTARGET hello.exe
TARGETTYPE exe
UID 0
SOURCEPATH .
SOURCE slhello.c
SYSTEMINCLUDE epoc32includelibc epoc32include

LIBRARY estlib.lib euser.lib
STATICLIBRARY ecrt0.lib

这个项目必须包括重要的库文件estlib.lib(也就是C标准库),和euser.lib(E32的用户库),whose services are used by STDLIB

这个工程也可以使用STATICLIBARY关键字来链接ecrt0.lib库。This file provides the E32Main() entrypoint for a .exe. It also provides other services including command-line parsing, and it calls main().

The SYSTEMINCLUDE path specifies epoc32includelibc. This is the directory in which STDLIB's header files are installed.

这里不做多深入的叙述了,如果有这方面的需求,可以参见SDK:)

<>
[Data And Time Handling Overview]
处理数据和时间值。
系统时间的设定是通过系统静态函数API User class
System locale settings, which affect date and time formatting, are set through TLocale in the Locale Settings API.

这组API有三个重要组成:point in time, time utilities, and time interval.

[Using Date and Time Handling]
Points in time是由TTime类存储和操作的,TTime使用了64-bit的整数来表现时间,它可以精确到微秒。一共有580000年的时间跨度,够用了吧:)

日期/时间和它的组成部分都可以在TDateTime中设置和得到,这个类是TTime的更友好的表现形式,它允许用户很方便的访问到year, month, day, hour, minute,second和微秒这些时间的组成部分。It does not support manipulation of the date/time, or of its components, but may be converted into a TTime, and vice versa.

<>
[DBMS overview]
提供了一个关系数据库的接口。
DBMS定义了一个常用的关系数据库访问API,允许不同的数据库被访问。这里有两个解决方案:a small and relavtively lightweight client-side implementation; and, for when multiple clients must have write access to a database, a client-server implementation.

The File Stores API defines a sophisticated file storage, called permanent file stores, that allows individual entries in a file to be modified.数据库使用这些存储机制来完成底层的数据存储。

[Interface to DBMS database overview]
Defines interfaces for opening databases, defining database schemas, and performing transactions.

这组API有三个重要的组成:abstract database, store database, and named database.

[DBMS rowsets overview]
Allows data contained in a database to be retrieved, searched, and modified.

这组API有三个重要的组成:rowset base, table rowset, and SQL view

[DBMS columns, column sets, and keys overview]
Defines column, column set, and index key structures.

这组API有三个重要的组成:column, column set, and index key.

[DBMS sharing databases overview]
Provides access to a server that allows databases to be accessed by multiple clients.

这组API有两个重要的组成:DBMS server session, and database change notifier.

[DBMS incremental operations overview]
Allows long-running database operations to be performed in steps, so that a user program can remain responsive to other events.

<>
[Descriptor Arrays Overview]
为descriptors提供专用的动态数组,元素可以自由的添加进数组,而不管描述符是什么类型。

<>
[Dynamically Loading Link Libraries Overview]
在程序执行时动态加载库。
These interfaces are used by programs that need to load libraries at run-time, that have a common interface, but different concrete behaviour. Because of this relationship between interface and behaviour, such libraries are called polymorphic DLLs.

<>
Notifies a program of changes in the system environment relating to time, local, power, and thread death.

<>
[File Server Client Side overview]
Provides an application interface to file systems.

文件访问是由EPOC server提供的,the file server。它提供了本地文件系统(ROM, RAM和removable media)还有一个允许动态安装文件系统的接口,如通过网络连接到远程的磁盘上。

这个磁盘、目录和文件层次就是VFAT,它可以使得文件系统与桌面PC兼容。

<>
[File Stores Overview]
提供基于文件的结构数据存储,using networks of streams.

The File Stores API is based on the abstract store types defined by the Stores API. The underlying file handling is provided by the File Server.

The permanent file stores defines in this API are used by the relational database API, DBMS,for data storage.

<>
[Handle overview]
允许一个线程或进程被另一个线程或进程标识和管理。Handles allow a client to access, or refer to, Kernel Object.


<>
从左到右比较两个文本缓冲区。

在两个文本缓冲区中做渐增匹配的比较操作,如,在"garage"和"gander"中匹配的是"ga"。
这组API有四个重要组成:incremental matcher base class, buffer matcher, pointer to descriptor matcher, and reaizable buffer matcher.

<>
Resource files contain data separate from executable code. Their main uses are for defining user interfaces components and for storing localisable data.

[Introduction to the resource file interface]
Resource files contain data in numbered resources. A resource file has the following format:
---------
header
--------
resource1
resource2
resource3
...
last resource
-------------------
index
------
资源文件使用资源编译器生成的,这里的index可以凭一个数字id来查找到合适的资源,在一个资源文件中可以有最多4096个资源。每个资源都包括二进制数据。

那些处理资源的函数都封装在RResourceFile类中,这个提供了如下的函数:
1、打开和关闭文件
2、读取资源
3、支持使用多个资源文件

一般来说,读取资源后都将其放在一个指定大小的缓冲区中,随后逐步的分析并将数据放在C++类中,最后再释放这个缓冲区。
TResourceReader类可以帮助简化资源数据分析的过程。

[Basic resource file use]
1、in a resource file, define structs or use appropriate pre-defined structs and then define resources that use those structs.

2、run the resource compiler to produce both a generated header file and a resource file. The generated header file defines the symbols which a program uses to refer to the resources.

那些希望使用资源的程序应该使用如下步骤:
1、it includes the generated header file in the appropriate source file to get symbolic access to the ids of the resources contained within the file

2、opens a RResourceFile object, specifying the generated resource file name

3、reads any resource it wishes; the resource is identified by a symbolic id which has been #defined as a number; the content of the resource is read into a binary descriptor, derived from TDesC8.

4、converts the binary descriptor into whatever target format is appropriate for the data in the resource file

5、discards the descriptor, if appropriate, when the binary descriptor has been fully converted into its target format

6、closes the RResourceFile when all operations on the resource file are complete

The resource text can be changed and the resources recompiled without altering or recompiling the C++ program. For example, to alter the language used by text strings.

<>
Provides idioms and frameworks by which processes can pass requests and data to other running processes.

[Asynchronous Services Overview]
Provides low-level and high-level idioms by which one thread or process in EPOC can request services from another.

Client programs typically use these idioms when accessing system services such as windowing, or telephony. This process is so fundamental that the basic structure of nearly all EPOC applications is based on its encapsulation in the active object framework.

<>
提供和本地密切相关的信息,包括日期和时间格式,度量单位等。

<>
This API should be used by applications that display names of plug-ins to users. Some devices allow users to switch between different languages. On such a device, lists of plug-in names displayed to users need to be localised.

<>
提供有关实型数操作。

<>
提供有关内存是如何分配和使用的函数。

EPOC程序中的函数都是和内存密切相关的,这是个有限的资源,必须要小心对待。特别是the event of error conditions. 基于这个理由,异常的处理和内存的管理在支持Cleanup的API中是息息相关的。

一般来说,清除栈只处理基于CBase的类和未知类型(TAny*)对象——这可以通过简单的内存释放来清除。

大部份客户程序都不需要直接使用函数,它们重要是在线程间或进程中共享内存区域上时使用。


<>
提供引用计数对象和相关的包容器。
这个东西是server端代码中大量使用的,主要用来记录server提供的给多个client的资源的使用情况。The major motivation for the form of the API is to provide such functionality for the Kernel, which uses them in this way for system objects such as mutexes, threads, etc. The various container classes in the API provide the support for tracking the use of groups of such objects.

<>
[Stores Overview]
Provides structured data storage, using networks of streams.

<>
[Store Streams Overview]
Provides stream types suitable for use in store(structured data storage).

Store Streams API is based on the abstract stream types defined by the Streaming API. They are designed to be used in conjunction with the structured data storage defined by the Stores API.

<>
[Streaming Overview]
Streams abstract the external storage of data(typically objects)

The Streaming API is abstract. It defines interfaces for reading and writing data to and from storage, but not what that storage is. Derived classes in other APIs provide particular implementations of streams:
file streams, as defined in the File Stores API

streams used as part of a network of related streams, called a store, as defined in the Stores API memory-based streams, as defined in the Memory Streams API

encrypted streams, as defined in the Encrypted Streams And Stores API

<>
提供各种系统函数。系统静态函数,由User类提供,typically either relate to the current thread, or its heap, or system-wide properties, such as system time.

<>
Provides a core set of error codes that may be returned by System APIs.

<>
Provides access to processes, threads, thread-local storage, and access synchronisation.
These APIs provide support for a programming style that employs multiple threads or processes that share resource protected by synchronisation mechanisms such as mutexes.

<>
Provides timers that asynchronously notify an application after an interval or at a specific time.

The User class in the System Static Functions API provides simple functions to suspend a thread for a given interval or until a specific time.

<>
Manipulates globally unique identifiers (UIDs).

To guarantee uniqueness, all UID values are assigned to developers centrally by Symbian.

<>
Encapsulates version information.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-126261/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10294527/viewspace-126261/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值