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 » Newbie corner » Writing hexadecimal to files
Re: Writing hexadecimal to files [message #32521 is a reply to message #32517] Mon, 23 May 2011 18:10 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi tjerk,

You are doing it almost right Smile The problem is that in Upp::String (unlike std::string) \x00 terminates the string. One possible solution is to use Vector instead:
	Vector<byte> v;
	v.Add('a');
	v.Add(0);
	v.Add(4);
	v.Add('\x00');
	v.Add('x');
	FileOut f(myfile);
	f.Put(v,v.GetCount);
	f.Close();

Another, sometimes simpler, approach is to use the binary interface of FileOut, the Put* methods (the same goes for FileIn and Get* for binary reading):
	FileOut f(myfile);
	f.Put('a',1);
	f.Put('\x00',3);
	f.Put('b',1);
	f.Close();

See Stream documentation for details.

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: dll example errors when trying
Next Topic: How to reference value of an item on a layout?
Goto Forum:
  


Current Time: Fri Jul 18 14:36:59 CEST 2025

Total time taken to generate the page: 0.05113 seconds