XCODE下对UNICODE的显示支持

 
              对于不同系统文字乱码的情况的分析:主要是因为每个地区都使用自己的编码标准,虽然相同的二进制码,但在不同的语言系统中对应的字符却不一样。如何解决全球字符统一的问题呢? UNICODE就是为此而诞生的。
       现在我就谈一下MAC平台下XCODE对UNICODE的显示支持。MAC操作系统从X系列后就开始支持UNICODE的显示了。如何在XCODE中对UNICODE码做显示呢?
       苹果下的绘图环境分为QuickDraw 和 Quartz,但是两者都是建立在OpenGL的绘图环境上的,都是对OpenGL的封装。
       每一个绘图环境都有一个对应的Context,相当于Windows 下得DC,这个绘图环境可以指向窗口,也可以指向BMP文件,或是内存文件。
       1:Get a Context
首先要获取一个Context。 QuickDraw下可以通过通过QDBeginCGContext 函数将一个Cgrafpt 的对象穿换成一个 Context 对象,整个结束后可以通过QDEndCGContext来释放。
       2:Creating a Text layout Object
              Object: ATSUTextLayout myTextLayout;
              Create: ATSUCreateTextLayoutWithTextPtr(
                                   (UniChar *)dataPtr,                     // point Unicode data
                                   KATSUFromTextBeginning,          // offset from beginning
                                   myTextBlockLength,                    // length of the text range
                                   1,                                              // number of style runs
                                   KATSUToTextEnd,                      // length of the style run
                                   &myArrayOfStyleObjects,   
                                   &myTextLayout);
       3:Set the layout Object attributes
              Line Object:
ATSUAttributeTag   theTags[] = {KATSULineFlushFactorTag,
KATSULineJustificationFactorTag};
                     ByteCount           theSizes[] = {sizeof(Fract), sizeof(Fract)};
                     Fract                     myFlushFactor       = KATSUStartAlignment;
                     Fract                     myJustFactor               = KatsuFullJustification;
                     ATSUAttributeValuePtr   theValue[] = {& myFlushFactor, & myJustFactor};
                     Associate the line and layout Attributes with text layout:
                            ATSUSetLayoutControl ( myTextLayout,     2,
theTags, theSizes, theValuse);
              Context Object:
ATSUAttributeTag   theTags[0] = {KATSUCGContextTag};
ByteCount             theSize[0]       = sizeof(CGContextRef);
ATSUAttributeValuePtr theValue[] = &myCGContext;
                     Associate the line and layout Attributes with text layout:
                            ATSUSetLayoutControl ( myTextLayout,     1,
theTags, theSizes, theValuse);
       4: Drawing Text
              ATSUDrawText( myTextLayout, KATSUFromTextBeginning,   KATSUToTextEnd,
                                          myXLocation,       myYLocation);
       OK!以上就是XCODE下对UNICODE的显示支持,希望能帮助大家。
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值