U++ framework
Do not panic. Ask here before giving up.

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: 1796
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: Wed Apr 29 09:49:48 GMT+2 2026

Total time taken to generate the page: 0.00573 seconds