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 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Oblivion wrote on Sat, 17 April 2021 18:20Hello 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..
|
|
|
Goto Forum:
Current Time: Thu Apr 25 11:41:36 CEST 2024
Total time taken to generate the page: 0.01448 seconds
|