UNICODE 问题!!! UP 有分!!
CMapLayer::CMapLayer(CDemo2Doc* pDoc, CArchive& ar)
{
CString str, str1;
int i, j, k;
CMapObject* object;
m_pDoc = pDoc;
m_nMaxPoint = 0;
m_bCanDraw = true;
while ( ar.ReadString(str) )//一行一行的读,田加的
{
str1=GetFirstPara(str);
if(str1=="Region")
{//区域图元
j=GetSecondPara(str);//读多边形个数
for(i=0;i<j;i++)
{//创建多边形对象
ar.ReadString(str);
k = atoi(LPCTSTR(str));//读当前多边形端点数
object = new CMapRegion(pDoc, ar, k);
m_aObject.Add(object);
m_nMaxPoint = m_nMaxPoint > object->m_nMaxPoint ? m_nMaxPoint : object->m_nMaxPoint;
}
}
else if(str1=="Pline")
{//线图元
j=GetSecondPara(str);//读折线端点数
object = new CMapPLine(pDoc, ar, j);
m_aObject.Add(object);
m_nMaxPoint = m_nMaxPoint > object->m_nMaxPoint ? m_nMaxPoint : object->m_nMaxPoint;
}
else if(str1=="Text")
{
object = new CMapText(pDoc, ar);
m_aObject.Add(object);
m_nMaxPoint = m_nMaxPoint > object->m_nMaxPoint ? m_nMaxPoint : object->m_nMaxPoint;
}
}
}
本想通过行读while ( ar.ReadString(str) ) 来取到文本文件中的每一行,然后判断关键字if(str1=="Region"),if(str1=="Pline"),if(str1=="Text") 来进行绘图,但现在取出的STR是乱码,后来才发现,STR内读取文本是按双字节进行的,每次读两个字符,因此产生了类似方块字的乱码,有什么解决方案吗?该程序由VC版本移植.VC下正确.