Click here to Skip to main content
15,900,258 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Unicode to Hex conversion Pin
MANISH RASTOGI28-Aug-09 22:57
MANISH RASTOGI28-Aug-09 22:57 
GeneralRe: Unicode to Hex conversion Pin
msn9229-Aug-09 8:43
msn9229-Aug-09 8:43 
QuestionRe: Unicode to Hex conversion Pin
CPallini29-Aug-09 9:41
mveCPallini29-Aug-09 9:41 
AnswerRe: Unicode to Hex conversion Pin
msn9229-Aug-09 10:07
msn9229-Aug-09 10:07 
GeneralRe: Unicode to Hex conversion Pin
David Crow29-Aug-09 11:17
David Crow29-Aug-09 11:17 
GeneralRe: Unicode to Hex conversion Pin
CPallini29-Aug-09 11:53
mveCPallini29-Aug-09 11:53 
GeneralRe: Unicode to Hex conversion Pin
msn9229-Aug-09 12:43
msn9229-Aug-09 12:43 
GeneralRe: Unicode to Hex conversion [modified] Pin
msn9229-Aug-09 19:22
msn9229-Aug-09 19:22 
Ok, I figured it out.
It is because of the charset (windows-1251).

And to convert them to the hex format that firefox is using(windows-1251 charset), I had to replace each russian letter by hand with its hex equivalent in windows-1251 charset.

I know, it's not the best way, but I couldn't find better one:
Just in case, if someone needs it:
/*----------------------------------*/
//***Windows-1251 charset to Hex***
//If works, it is written by
//Siroj Matchanov(aka tech,msn92)
//if it doesn't I dunno who wrote it
//Recources used:
//http://www.science.co.il/language/Character-Code.asp?s=1251
/*----------------------------------*/

void Win1251ToHex(
	CString &input, /*(windows-1251/ascii charset)*/
	CString &hex /*Output (in hex)*/
)
{
hex=L"";
for (int i=0;i<input.GetLength();i++)
{
	//each char represents a unique number (e.g. int('Ў')=1038)
	int ii=input[i];
	//russian letters represent numbers that are greater than 1000
	if(ii>1024){
			//---------------------------------//
			//   Uppercase&Lowercase Letters   //
			//  А-Я-а-я  (1040-1071-1072-1103) //
			//---------------------------------//
	   if((ii>1039)&&(ii<1104)){
	     BYTE x=0xC0;
	     x=x+(ii-1040);
	     hex.Append(L"%");
	     hex.AppendFormat(L"%x",x);
	   }else{
			//------------------------//
			//    Special symbols     //
			//------------------------//
		switch (ii)
		{
		case 8218:
			{
				hex.Append(L"%82");//
				break;
			}
		case 8222:
			{
				hex.Append(L"%84");//
				break;
			}
		case 8230:
			{
				hex.Append(L"%85");//
				break;
			}
		case 1038:
			{
				hex.Append(L"%A1");//Ў
				break;
			}
		case 1118:
			{
				hex.Append(L"%A2");//ў
				break;
			}
		case 1025:
			{
				hex.Append(L"%A8");//Ё
				break;
			}
		case 1105:
			{
				hex.Append(L"%B8");//ё
				break;
			}
		case 8470:
			{
				hex.Append(L"%B9");//
				break;
			}
		}
	   }
	//Because they are not used usually,
	//this code doesn't convert the following symbols:
	//ЂЃ‚ѓ„…†‡€‰Љ‹ЊЌЋЏђ‘’""•–—™љ›њќћџЈ¤Ґ¦§©«¬®Ї°±Ііґµ¶·є»јЅѕї
	//If you want them to be in windows-1251 charset format hex...
	//...then continue the code yourself please :)
	//(Almost) any other symbol in windows-1251 charset has
	//the same hex value as ascii symbols do.
	}else if(ii<127){
		hex.Append(L"%");
		hex.AppendFormat(L"%x",ascii[i]);
	}
}
}


modified on Sunday, August 30, 2009 2:09 AM

QuestionWhat is the maximum value of character of LPCWSTR lpCommandLine, for CeCreateProcess. Pin
Le@rner28-Aug-09 21:12
Le@rner28-Aug-09 21:12 
AnswerRe: What is the maximum value of character of LPCWSTR lpCommandLine, for CeCreateProcess. Pin
Rajesh R Subramanian28-Aug-09 21:48
professionalRajesh R Subramanian28-Aug-09 21:48 
AnswerRe: What is the maximum value of character of LPCWSTR lpCommandLine, for CeCreateProcess. Pin
Hristo-Bojilov29-Aug-09 0:04
Hristo-Bojilov29-Aug-09 0:04 
QuestionShow local html file Pin
includeh1028-Aug-09 20:25
includeh1028-Aug-09 20:25 
AnswerRe: Show local html file Pin
kilt3-Sep-09 4:43
kilt3-Sep-09 4:43 
GeneralRe: Show local html file Pin
David Crow14-Sep-09 4:00
David Crow14-Sep-09 4:00 
QuestionWhat the Message for Update UI on DialogBase App? Pin
Max++28-Aug-09 20:22
Max++28-Aug-09 20:22 
AnswerRe: What the Message for Update UI on DialogBase App? Pin
Rajesh R Subramanian28-Aug-09 20:37
professionalRajesh R Subramanian28-Aug-09 20:37 
GeneralRe: What the Message for Update UI on DialogBase App? Pin
Max++28-Aug-09 21:47
Max++28-Aug-09 21:47 
AnswerRe: What the Message for Update UI on DialogBase App? Pin
Rajesh R Subramanian28-Aug-09 21:50
professionalRajesh R Subramanian28-Aug-09 21:50 
GeneralRe: What the Message for Update UI on DialogBase App? Pin
Max++28-Aug-09 22:21
Max++28-Aug-09 22:21 
GeneralRe: What the Message for Update UI on DialogBase App? Pin
Moak29-Aug-09 0:09
Moak29-Aug-09 0:09 
QuestionIOCP memory question Pin
lcx31563382028-Aug-09 19:09
lcx31563382028-Aug-09 19:09 
AnswerRe: IOCP memory question Pin
Richard MacCutchan30-Aug-09 6:58
mveRichard MacCutchan30-Aug-09 6:58 
QuestionRe: IOCP memory question Pin
lcx31563382031-Aug-09 2:11
lcx31563382031-Aug-09 2:11 
AnswerRe: IOCP memory question Pin
Richard MacCutchan31-Aug-09 4:08
mveRichard MacCutchan31-Aug-09 4:08 
QuestionMake ActiveX have it's own thread Pin
manchukuo28-Aug-09 17:41
manchukuo28-Aug-09 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.