Dear all, I have a small script wich is supposed to process two images passed as arguments in commandline, but I don't know how to handle these arguments when they are with non latin characters. Here is an example of command python.exe myscrit.py --first=xvalue "image1.png" "οισξφσιο.png" If I isolate the arguments as follows import sys, getopt opts, args = getopt.getopt(sys.argv[1:], '', ['first=']) opts = dict(opts) fval_name = opts.get('--first', 'xvalue') and I print the second `args` I end up with a string like this `??s?fs??.png`. What am I doing wrong and how can I fix it? I also tried the following …

Member Avatar
Member Avatar
+0 forum 3

Hi DW. How can one read a file or change a file bits without reading the entire file. But first of all how can I read a file in such a way that I get it's bits. I want to read MP3 file and change it bits but I don't want to change the information stored on it like artist name, album year, but want to read it and change bits in such a way that MP3 players won't recognize this file as MP3, and most importantly how to change the file back to original bits. Some one also mentioned …

Member Avatar
Member Avatar
+0 forum 7

**Read title.** username = base64.b64encode(username)+'\n' This is what I thought would have worked, but it comes up with an error, "TypeError: can't concat bytes to str", meaning that I cannot add +'\n' to the end of the code. If there is anyway anyone knows how to write the byte of base64.b64encode(username) to a file line by line, please help!

Member Avatar
Member Avatar
+0 forum 2

Hi, I'm going to send a byte to the .dll to retrieve machine information. Right now I'm using the string to pass the value to CBMReader and I able to retrieve the value. Dim Devc as String Dim CBMReader as String For i = 0 To 50 If tempDev = "" Then tempDev = "z" Else Devc = Devc & tempDev End If Next i CBMReader = Devc status = CBM_EnumerateReader(CBMReader) debug.print CBMReader Result for CBMReader is MachineName. If i used this code to convert the string into byte, my vb6 forcely been close. dim bytes() as byte bytes = …

Member Avatar
+0 forum 0

Hi All, My problem is: i'm trying to convert byte[] into image. The byte[] comes from JSON and it's in this format: `"4oCwUE5HDQoaCgAAAA1JSERSAAAAfwAAAFAIBgAAADBHwqrDsAAAAAlwSFlzAAAAJwAAACcBKgnigJhPAAAgAElEQVR4xZPCrMK9ecWSZcOZfcOfw7c5w5vCvW/CqXp..."` it goes for another 100 lines. The code where the problem occurs: DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(PlayersListActivity.URL); httpPost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8")); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(httpEntity); // if this is null the web service returned an empty page if(httpEntity == null) // response is empty so exit out return null; String jsonString = EntityUtils.toString(bufferedEntity); // again some simple validation around the returned string if(jsonString != …

Member Avatar
+0 forum 0

Hi Im using windows form applicaton and try using a method that returns a value and have a parmeterlist input. I try to creat a program that converts a number of kilobytes (KB) to byte. The program's user to specify the number of KiB and the program will print the same number of bytes. For conversion of KB to change the program should call a separate method that you have defined. The method is via its parameter list to load KiB number, convert the number of KB to the corresponding value in bytes and return that value. Any idea

Member Avatar
Member Avatar
+0 forum 6

Hello good day. I have a quick question is anyone able to assist me in saving a password file. I encrypted my password and so I want to save the salt and the encrypted password(which are byte arrays). I tried using a properties file, but I soon found out that I can't. Can anyone assist me in saving these byte arrays and retrieving them please?

Member Avatar
Member Avatar
+0 forum 5

Hi, I've been trying to send a long integer from an Arduino to my C++ program via the serial port. There seems to be many examples of this when i search, but I've not had much luck except for one example. This example seems to work, but not when I send a negative integer. I'm not sure if it is my arduino code or my c++ code, or both that needs changing. Does anyone know how I could adjust this to work with negative numbers too? // Ardunino Code - Sends 4 bytes to C++ program on PC void IntegerToBytes(long …

Member Avatar
Member Avatar
+0 forum 4

Hey, Iv been looking around for a simple way (meaning less than 10 lines) to reverse the order of my bytes in a byte array. At the moment my code is: public byte[] outputarray() { byte b[] = new byte[10]; ByteBuffer buf = ByteBuffer.wrap(b); buf.putLong(output); } The problem is that the array is on the wrong order. So when i save the byte array to the file its contents in binary are in reverse. So anyone know the easiest way or possibly an api way to easily reverse the bytes, i tried flip but it doesent seem to be what …

Member Avatar
Member Avatar
+0 forum 4

So i have a working network file transfer program now (if you want to see some of the code look at my other '[article](http://www.daniweb.com/software-development/java/threads/426357/networking-in-java-not-doing-it-right)'). But now that im trying larger files, im running into a problem where i run out of memory (which is understandable when the array is 1 000 000+ in length). I cant figure out how to split a file up into smaller arrays. At the moment i just load the file into one big array: byte[] fileArray; JFileChooser chooser = new JFileChooser(); chooser.showDialog(this, "Send"); File file = chooser.getSelectedFile(); Path path = Paths.get(file.getAbsolutePath()); try { fileArray = …

Member Avatar
Member Avatar
+0 forum 15

Hi all, I'm sure this is a n00b question, but I can't seem to get my head around it! I have a 4 BYTE array which I want to display as a decimal value. For example, in the array it contains the hex values: 00 05 7d a4, and I would like to display 359,844. Any clues on how I go about this? I have tried: BYTE freeBlocks[4]; memcpy(freeBlocks, trackInformation + 16, 5); _tprintf(_T("%u"), strtoul((char*) freeBlocks, NULL, 16)); But this only prints out 0. I know freeBlocks contains the correct values as when I do: for(int i; i < 4; …

Member Avatar
Member Avatar
+0 forum 2

i have an ASP web services to change byte array that given from the client and change it to a file and save it in the web server the code is like this : [CODE] [WebMethod] public string UploadFile(byte[] f, string fileName) { try { MemoryStream ms = new MemoryStream(f); String path="/myfile/"; String location=HttpContext.Current.Server.MapPath(path); FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(path)+fileName, FileMode.Create); ms.WriteTo(fs); ms.Close(); fs.Close(); return "OK"; } catch (Exception ex) { return ex.Message.ToString(); } } [/CODE] the web services need byte array and file name.. i build the client in php [B]upload.php[/B] [CODE] <html> <body> <form action="action1.php" method="post" enctype="multipart/form-data"> Pilih File …

Member Avatar
Member Avatar
+0 forum 2

[CODE]sizeA = 2**28 M = [0]*sizeA[/CODE] The above code creates an array but, each element is 4 bytes each. How do create a large byte array with type 'B' (eight bits unsigned)? I would like it to be as large as possible. I need it for a sieve prime number program.

Member Avatar
Member Avatar
+0 forum 10

Hi there, My question is how could I output byte value (meaning zeros and ones) to screen. I just want to try some shifts and see how it works.

Member Avatar
Member Avatar
+0 forum 14

how to free memory of byte array... code[CODE]for(int j=0;j<count;j++){ buffer=null; //[COLOR="Red"]free the memory by set as a null but not working????? shows array index out of bound exception for the second time[/COLOR] buffer= new byte[size]; //byte mem alloc temp2=di.read(buffer,total,size);// read buffer total=total+temp2; fo=null; ds=null; fo= new FileOutputStream(flist[j]); ds= new DataOutputStream(fo); ds.write(buffer,0,size); System.out.println("write: "+(j+1)); fo.close(); ds.close(); }[/CODE] exception occur at run time... [CODE]Exception in thread "main" java.lang.IndexOutOfBoundsException at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(Unknown Source) at java.io.DataInputStream.read(Unknown Source) at filesplitandjoin.main(filesplitandjoin.java:57)[/CODE] src code attached:(

Member Avatar
Member Avatar
+0 forum 2

Lookup table is usually the fastest method to find function value, if number of values is small. Here we demonstrate the principle by using task of showing the value of byte as binary string or transforming binary string to byte binary value.

Member Avatar
+0 forum 0

Hey, I'm working on a project where we have to stream files from a server app to clients. I have it all working nicely, but we have a special client type that cannot save files to HDD, not even temporarily. I can get the byte stream from server to this special client, so only the data handling in the client side is the problem. I was thinking, is there any way to open the streamed files in the client app without saving them first? For example, if I send a .JPG file from server to client, how can I open …

Member Avatar
Member Avatar
+0 forum 7

Hey guys, I'm working on a project to use Huffman trees to compress a text file into binary. For instance, based on the frequency of the characters in a string like "aardvark", a - 3 r - 2 d - 1 v - 1 k - 1, compression using a Huffman tree could look something like 001011011100101111, assuming that the most frequent character (a) would be stored using the least number of bits (0), and one of the least frequently occurring characters (k) would be stored with the most number of bits (1111), and so forth. I am able to …

Member Avatar
Member Avatar
+0 forum 2

Hey guys, quick questions! 1- How can I check the size of a variable? Size in bytes, not length. (; 2- What data can be stored into byte variables? And what the maxium size of the variable? 3- How do I store data inside a byte variable? Thats all for now. Thanks!

Member Avatar
Member Avatar
+0 forum 5

Hi guys! Well I'll be quick, I just want to know how the formula below works. Ls = least significant bit; Ms = most significant bit; Ls | Ls1 << 8 | Ls2 << 16 | Ms << 24 This formula is intended to turn four separate bytes into a single 32 bit number in java. Can you give me any example about how it works? Thanks!

Member Avatar
Member Avatar
+0 forum 1

Need to insert byte array value in to a column using bcp bulk copy. Any way?

Member Avatar
+0 forum 0

Hi all, I am stucked at this problem - net to let user set string as byte eg. "0xFF", And parse it to byte. Problem is, that using... [CODE] byte byteVar = (byte) "0xFF"; [/CODE] ...is incompatible. Nice page about this is [URL="http://www.herongyang.com/Java/Byte-Data-Type-Implicit-Casting.html"]there[/URL]. Any idea how solve this? Thx for your help..

Member Avatar
Member Avatar
+0 forum 4

I have a byte array which looks something like 01 00 02 00 73 45 69 A5 So i have to read first 2 bytes and convert it into integer to get its value. Same for next 2 bytes and then next 4 bytes. Here the value for first 2 bytes (01 00) is 1, next 2 bytes (02 00) is 2. So could some one help me on this.

Member Avatar
Member Avatar
+0 forum 4

Dear All , The question is quite simple for all of you . I have a binary file . A description for this file says that : "first 2 bytes in the header is the number of records" I have opened this file and loaded it into bytes by this function [code] Public Shared Function ReadBinaryData(ByVal path As String) As Byte() ' Open the binary file. Dim streamBinary As New FileStream(path, FileMode.Open) ' Create a binary stream reader object. Dim readerInput As BinaryReader = New BinaryReader(streamBinary) ' Determine the number of bytes to read. Dim lengthFile As Integer = FileSize(path) …

Member Avatar
Member Avatar
+0 forum 4

Hi! Could you tell me what did I do wrong in the code bellow? I try to read one line from a file, but it shows on the screen only unknown characters(different from the characters I have in the file). [Code] GetLine Proc Hand:HANDLE, pBuf:DWord Local Len:DWord Local rLen:DWord Local Chr:Byte Mov Len, 0 .Repeat Mov rLen, 0 Invoke ReadFile, Hand, Addr Chr, 1, Addr rLen, NULL Invoke StdOut, Addr Chr Mov Ebx, Len Mov Ah, Chr Mov Byte Ptr [pBuf+Ebx], Ah Inc Len .Until Chr == 10 || Chr == 0 Mov Byte Ptr[pBuf+Ebx], 0 Mov Eax, Len Ret …

Member Avatar
+0 forum 0

Okay, so C++ has no specific byte class, but what they do have is an unsigned char class to convert ints/doubles/floats to binary/bytes. In trying to convert some Java to C++, I am trying to keep some of the function signatures the same or close to the same, and in so doing, have realized that if you have an unsigned char*, you can't actually get the size of the number of bytes this represents. It was an easy solution to convert though because I was able to do memcpy of all the primitives into the char* and voila, done. This …

Member Avatar
Member Avatar
+0 forum 8

Hi, I first convert the image on the server application in bytes: [code] //server public void sendImage(File file) throws IOException { ByteArrayOutputStream baos=new ByteArrayOutputStream(1000); BufferedImage img=ImageIO.read(new File(file.getAbsolutePath())); ImageIO.write(img, "jpg", baos); baos.flush(); os.write(baos.toByteArray());// this is a "new DataOutputStream(clientSocket.getOutputStream());" System.out.println("Done! Length is:"+baos.toByteArray().length); baos.close(); } [/code] Then my application freezes when trying to convert the bytes array back to image. [code] //client public void receiveImage() throws IOException { byte[] bytearray = new byte[4096]; is.readFully(bytearray);// "new DataInputStream(clientSocket.getInputStream());" here my app freezes. and i don't knwo array length. BufferedImage imag=ImageIO.read(new ByteArrayInputStream(bytearray)); ImageIO.write(imag, "jpg", new File("abc.jpg")); this.setLayout(new FlowLayout()); this.add(new ImagePanel(imag)); this.validate(); } [/code] I probabily done …

Member Avatar
Member Avatar
+0 forum 1

The End.