在MFC视图中显示阿拉伯语/Unicode [英] Display Arabic/ Unicode in MFC View

查看:485
本文介绍了在MFC视图中显示阿拉伯语/Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在MFC视图类中显示一个简单的Unicode字符串.该问题可以简化为以下代码

I am trying to display a simple Unicode string in an MFC view class. The problem can be simplified to the following code

CString arabic (_T("مرحبا العالم"));
pDC->TextOutW (50, 50, arabic);

问题是MFC窗口显示的是条形而不是阿拉伯字符,如下面的屏幕快照所示.有人可以告诉我我在做什么错吗?

The problem is that the MFC window displays bars instead of the Arabic characters as shown in the screenshot below. Can someone tell what I am doing wrong?

如果这很重要,我正在使用VS 2003.

I am using VS 2003 if that matters.

当我在设备上下文中选择字体对象时,应用程序的行为发生了变化,但仍然不正确;它显示以下字符,好像我使用的是错误的代码页:

When I have selected a font object in the device context, the behaviour of the application changes but it's still not correct; it displays the following characters as if I am using the wrong codepage:

推荐答案

这意味着所选字体没有可用的字符.

This means that the selected font does not have the chars available.

您必须选择一种在设备上下文中具有所需字形的字体.

You have to select a font that has the glyphs you need into the device context.

类似这样的东西:

CFont font;
font->CreateFont(16,0,0,0,400,FALSE,FALSE,0,ANSI_CHARSET,
        OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
        ANTIALIASED_QUALITY,DEFAULT_PITCH|FF_SWISS,
        "Tahoma");
pDC->SelectObject(font);

这篇关于在MFC视图中显示阿拉伯语/Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆