Please post in plain text format. Only you have the power to format your email the way we will see it... using the default HTML format only leads to odd wraparounds and weird characters that you don't know about when you send but we have to wade through when we recieve it.

"Character" data is rather more complex now than it used to be in days of yore... what with Unicode UTF16 and UTF-8 and so on. You are getting into deep water trying to mix binary and text data. (I know enough to know I am no expert in this topic.) I highly recommend reading the article by Paul Murrell on reading binary data [1], but even that is unlikely to answer all the headaches you are diving into and it will probably stop being "on topic" for this list pretty quickly.

One key point is that you should read "raw" data, not "character" data when getting data out of files, even if they are opened in "binary mode".

[1] Viewing binary files with the hexview package. R News, 7(1):2--8, April 2007.

On Mon, 13 Jun 2016, Fahman Khan via R-help wrote:

I have written a following piece of code. 
binaryFile <- file("sampleBinary.dat", 'rb')>readBin(binaryFile, character(), 
endian="little")

I'm getting a warning message that says 

Warning message: In readBin(binaryFile, chracter(), endian="little") : 
incomplete string at end of file has been discarded

I did research on this topic but was still unable to solve.

My file contains the following binary values: 01101000 01100101 01101100 
01101100 01101111 00001010 which is hello in text. I just want to convert this 
into text. 

Any help would be appreciated.
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnew...@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to