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 » Community » Coffee corner » operation with ascii table character (Pascal x C++/U++)
Re: operation with ascii table character (Pascal x C++/U++) [message #56820 is a reply to message #56816] Sat, 17 April 2021 22:05 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Oblivion wrote on Sat, 17 April 2021 18:20
Hello BetoValle,


I see. AFAIK there is no such formatter in U++ (it is too specific, IMO).

But it is easy to create one, using operator overloading, for example.

String& operator*(String& s, int c)
{
	if(c >= 0x20 && c <= 0x7E)
		s.Cat(c);
	else
		s << "0x" << FormatIntHex(c, c < 256 ? 2 : 4);
	return s;
}

String& operator*(String& s, const String& q)
{
	for(int c : q) s * c;
	return s;
}

CONSOLE_APP_MAIN
{
	Vector<String> v;
	for(int i = 0; i < 256; i++) v.Add() * i;
	Cout() << v.ToString();
	
}


Best regards,
Oblivion


BTW, Format is extensible, so you can in fact add this somewhat weird formatter to Format..
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GLCtrl Linux dependency
Next Topic: Deprecated code
Goto Forum:
  


Current Time: Thu Apr 25 11:41:36 CEST 2024

Total time taken to generate the page: 0.01448 seconds