Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, friends)

plz, help me. I use Cmarkup for parse XML(encoded ANSI(cp1251)), where i use method xml.GetAttrib(MCD_CSTR szAttrib), i get path to file, where latin symbols - ? and number code 65533, cause i can't to use this path in code. How I will can to get work path?
it's my code:
C++
int ReadXMLAndWriteToPdf(string XMLFile, string DirDest)
{
	unsigned int index_sec = 0;
	if ((XMLFile != "") && (DirDest != ""))
	{
		CMarkup xml;
		char* ch_sec = "";
		wstring wstrXML(XMLFile.begin(), XMLFile.end());
		
		try
		{
			xml.Load(wstrXML);
			xml.FindElem();
			xml.IntoElem();
			xml.FindElem(MCD_T("img2PDF"));
			xml.IntoElem();
			dreamsys::DreamSysPDF pdf("", "");
			
			while (xml.FindElem(MCD_T("Tiff")))
			{
				wstring csName = xml.GetAttribName(0);
				if (csName.length() == 0)
					break;
				wstring str_path_ = xml.GetAttrib(csName);
				string str_path(str_path_.begin(), str_path_.end());
				string headerf =                 str_path.substr(str_path.find_last_of("."), str_path.length());
				pdf.addSection(ch_sec);
				if (stricmp(headerf.c_str(), ".jpg") == 0)        pdf.addImagePage(index_sec, TYPE_JPG, str_path);
				if (stricmp(headerf.c_str(), ".bmp") == 0) pdf.addImagePage(index_sec, TYPE_BMP, str_path);
				if (stricmp(headerf.c_str(), ".tif") == 0) pdf.addImagePage(index_sec, TYPE_TIFF, str_path);
				++index_sec;
			}
			int error = pdf.save(DirDest);
			return error;
		}
		catch (...)
		{
			return -1;
		}
	}

	return 0;

}
Posted
Comments
Jochen Arndt 20-Nov-14 5:10am    
What do you mean by 'latin symbols - ? and number code 65533'?
This is unclear (65533 is not a cp1251 character).

What is your project setting for encoding (Unicode or ANSI)?

You should try to print out the strings at each step to see where conversions fail.
Member 10403735 20-Nov-14 5:29am    
1.under debugging in VS2012 code for latin symbol screen ?- 65533 after return method getattrib()
2. My project settings for encoding Unicode.
3. Conversions fail after xml.GetAttribName(0);
Jochen Arndt 20-Nov-14 6:03am    
Please use the Reply button upon answering. Then an notification email is send. Otherwise I have to come back like now and see if anything has happened.

1. The code 65533 is the Unicode replacement character which is used when an unknown character comes in. So it would be helpful which character is on the input side (XML file). The code of 'latin symbol screen' would be helpful.

2. This makes it more clear to understand the code (CMarkup uses Unicode).

3. There is off cource no equivalent ANSI character for the Unicode replacement character 65533 / U+FFFD. So the Unicode to ANSI conversion places a character that is defined by the used conversion routine.
Member 10403735 20-Nov-14 7:02am    
O, thank you, i don't know about the button Reply.
1. This is pathes from XML:
"C:\Users\ibusygin\Desktop\Tiff\render - копия.JPG"
"C:\Users\ibusygin\Desktop\Tiff\render - копия (2).JPG"
"C:\Users\ibusygin\Desktop\Tiff\01.tif"
Jochen Arndt 20-Nov-14 7:06am    
But what is the content of the tag? I see two empty lines here but expect some kind of file name.
[EDIT]
Now I see the content.

It seems that the cyrillic letters can't be converted. Would be good to have the character codes of them (use a hex editor or a text editor that can show hex content to get the codes). But I always thought that all characters from the common code pages can be mapped to Unicode.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900