Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » A new function to Web Package Unicode-Escape-Javascript -> Unicode
A new function to Web Package Unicode-Escape-Javascript -> Unicode [message #33247] Wed, 20 July 2011 09:28 Go to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

I propose to include in the package a new feature WEB Unicode-Escape-Javascript -> Unicode.

For international characters in Javascript is used for special encoding non-Latin characters. Looks like: \ u0410 \ u0422 \ u0417 ....
For converting this encoding to Unicode, I needed a new function. I propose that its AEs in the package a new feature WEB Unicode-Escape-Javascript -> Unicode.

For international characters in Javascript is used for special encoding non-Latin characters. Looks like: \ u0410 \ u0422 \ u0417 ....
For converting this encoding to Unicode, I needed a new function. I have not found it, so I wrote in haste.

Maybe someone else will need.

I also want to note that some of the operations inside the function can be optimized. For example the plural multiplying by 16 can be replaced by bit shift.

String Javascript2Unicode(String s) {
	String res ;
	RegExp reg("\\\\u([0-9a-f]{4})",RegExp::MULTILINE);
	
	reg.Clear();
	
	int i_start,i_end,i_old=0;
	while (reg.GlobalMatch(s)) {
		reg.GetMatchPos(0,i_start,i_end);
		res << s.Mid(i_old,i_start-i_old-2);
		wchar wc[2] = {0,0};
		WString ws;
		String m = (String)reg[0];
		wc[0] = StrInt(m.Mid(0,1))*16*16*16
				+StrInt(m.Mid(1,1))*16*16
				+StrInt(m.Mid(2,1))*16
				+StrInt(m.Mid(3,1));
		
		ws = wc;
		String ss = ws.ToString();
		res << ss;
		i_old = i_end;
	}
	return res;
}


PS
Maybe there is already something like that? And I wasted 4 hours? Advise me if you know.


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Bug with socket
Next Topic: SSL server crash
Goto Forum:
  


Current Time: Sun Apr 28 16:24:10 CEST 2024

Total time taken to generate the page: 0.03677 seconds