w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
replace bytes with strings using Replace()
Assuming you are looking for the unicode char 0x00FF (ÿ) you just need to use the Unicode escape character `uxxxx. byte[] sttrings = new byte[pntrs[i + 1] - pntrs[i]]; stream.Position = pntrs[i]; stream.Read(sttrings, 0, sttrings.Length); Strs[i] = Encoding.GetEncoding("SHIFT-JIS").GetString(sttrings).Split('')[0].Replace("[u00FF]" , "/et"); If you really want to replace the byte values you may be able to use the String constructor that takes in a char[]. string replacementString = new String(new char[] {'[', '', (char)0xFF, ']'});

Categories : C#

How to replace word in notepad++ that begins with certain word plus number of bytes
2013d{10} will match 2013 and 10 digits after it. UPD: Here's a slightly improved version of the regex: 2013[0,1][0-9][0-3][0-9][0-2][0-9][0-5][0-9][0-5][0-9] that will still match, for example, 20130601000000 because it's a valid timestamp.

Categories : Regex

Need help - Getting an error: xrealloc: subst.c:4072: cannot reallocate 1073741824 bytes (0 bytes allocated)
OK. got it working. No more store stuff in a var and then echo $var to a file. Luckily, I had a same mount point on both source and target server i.e. if I go to /scm on source and on target, the mount (df -kvh .) shows same output for Share/NAS mount value. Filesystem size used avail capacity Mounted on ServerNAS02:/vol/vol1/scm 700G 560G 140G 81% /scm Now, instead of using the variable to store the whole output of ssh session calling sqlplus session, all I did is was to create a file on the remote server using the following code. ## Actual DB Change #db_change_run_op="$(ssh -qn ${pdt_usshu_dbs}@${dbs} "sqlplus $dbu/${pswd}@$dbn <<ENDSQL | tee "${sql_run_output_file}".ssh.log #set echo off #set echo on #set timing on #set time on #set server

Categories : Linux

Memory allocator for small chunks (Typ <= 16 bytes, Rare >= 64 Bytes, Max = 192) with static heap
OP: can anyone poke holes in my theory? In reading the first half, I thought out a solution using a bit array to record usage and came up with effectively the same thing you outline in the 2nd half. So here is the hole: avoid hard coding a 16-bite block. Allow your bit map to work with, say 20 or 24 byte blocks at the beginning of you development. During this time, you may want to put tag information and sentinels on the edges of the block. Thus you can more readily track down double free(), usage outside allocation, etc. Of course, the price is a smaller effective pool. After your debug stage, go with your 16-byte solution with confidence. Be sure to keep track of 0 <= total allocation <= (2048 - overhead) and allow a check of it versus your bitmap. For debug, consider f

Categories : C

Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes)
You're running out of memory, plain and simple. One possibility would be, rather than trying to shove every ID into $con and then print it out, print out each one as you read it. In other words, change: foreach ($ wqdb as $ row) { $ con. = $ row ['ID']; } echo $ con; into: foreach ($wqdb as $row) { echo $ row ['ID']; } That may help or it may not. If it doesn't, your problem may well lie with the way you're getting the data in which case you'll need to revisit that (such as using sections of the table with limit and offset).

Categories : PHP

Socket receives the correct bytes, bytes translate to empty string
Look for for a zero value ('') in your array of bytes before converting it to a string. private string GetString(byte[] data) { data = data.Where(b => b != 0).ToArray(); return Encoding.UTF8.GetString(data); }

Categories : C#

System.Net.ProtocolViolationException:Bytes to be written to the stream exceed the Content-Length bytes size specified
You seem to have the same issue as the question below. You need to check if the HttpMethod is a HEAD request; in that case you can't write bytes to the OutputStream and attempting to do so will throw the exception you are getting. ProtocolViolationException with Chrome

Categories : C#

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 122880 bytes)
Changing the memory limit only hides the problem, it doesn't solve it. You currently have 64MB of memory, which should be more than enough for your needs. If it's not, then there's almost certainly a leak in your code, or possibly an infinite loop. Instead of trying to hide the error in a corner, try fixing it. Look at where the error happens, see if you can find what the "last straw" is that makes it exceed the memory limit.

Categories : PHP

missing bytes while transfering files from client to server, the bytes values also represent some of the control characters
The issue is most likely that you sent binary data. And binary data can contain zeros. And zeroes are the normal string terminator. This means that when you do temp.str(Rbuffer) (assuming temp is a std::stringstream) then it only gets data from Rbuffer until the first zero. Instead of using e.g. std::stringstream use std::string: while(strBuffer.length() < fileSize) { char buffer[2048]; ssize_t n = read(sockets.newsockfd, buffer, sizeof(buffer)); if (n <= 0) { // An error, or connection closed if (n < 0) error("ERROR reading from socket"); break; } // Create a string of `n` bytes, including possible string terminators // and add it to out current buffer strBuffer += std::string(buffer, n); } The important t

Categories : C++

Move bytes in memory without replacing existing bytes and without big buffer
Problem described in my own question seems can be solved in two easy ways (look to pictures in question): 1) You have orange and green block, You need swap them - place orange block in buffer (because it is smaller), move green block, and them fetch orange block from buffer. Trade-off: easy, obvious, fast with small blocks Problem: in case of orange and green blocks has same sizes - You will need biggest buffer, and it may take a lot of memory 2) Use way described in question. You will be able to use buffer no bigger than GCD of two block sizes (orange and green). So, better to use two buffers: one with size of CPU register (8 bytes for my amd64) and one byte-sized buffer. So 1st You move (or shift) with register sized buffer using (GCD div 8) (for 64 bit systems) steps, and then You f

Categories : Python

C# Unsigned bytes Encryption to Java Signed bytes Decryption
Although you cannot use unsigned bytes in Java, you may simply ignore the issue. AES - and all modern symmetric ciphers - operates on bytes, and the input and output have been defined to be bytes (or octets). Input and output have been standardized by NIST and test vectors are available. If you look at the separate bit content of the bytes then {200,201,202} in C# and {(byte)200, (byte)201, (byte)202} in Java are identical. This is because Java uses two-complement representation of bytes. Take the number 200 as integer: this will be 11010000 in binary, representing the number -56 in Java if used in a (signed) byte in two complements. Now symmetric ciphers will simply transform these bits to another (normally using a full block of bits). Once you have retrieved the answer you will see

Categories : C#

How to avoid: Warning: POST Content-Length of 47820076 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
One thing what you can do is give a maximum size on the HTML form. <input type="hidden" name="MAX_FILE_SIZE" value="4194304" /> It's not bulletproof, but it has some impact. Why this is not so good is explained in this comment - it is only checked by PHP, so uploading will start and continue up until this limit is reached. My recommendation is that you could use that together with a javascript solution, as described here. It only works if javascript is enabled, of course.

Categories : PHP

My ByteBuffer is not placing it's bytes into a bytes array properly
When you read into a ByteBuffer, the offset of the buffer is changed. Which means, after the read, you need to rewind the ByteBuffer: while ((dat = rbc.read(bb)) != -1) { fout.write(bb.array(), 0, bb.position()); bb.rewind(); // prepare the byte buffer for another read } But in your case, you don't really need a ByteBuffer anyway, just using a plain byte array is enough -- and it is shorter: final InputStream in = url.openStream(); final byte[] buf = new byte[16384]; while ((dat = in.read(buf)) != -1) fout.write(buf, 0, dat); Note that in Java 1.7, you can use that: Files.copy(url.openStream(), Paths.get(fileLocation));

Categories : Java

How a bmp file bytes sorted as little endian, and gives me the first 2 bytes reverse?
The first byte is 'B' (0x42), the second byte is 'M' (0x4D) A little endian uint16_t would see this as 0x4D42 which is what you are reading. Try the following instead for a endian independent solution. char BM[3]; BM[2] = ''; if (fread(BM, 1, 2, file) && (strcmp("BM",BM)==0)) { printf("The file actually is a bmp file. "); } By the way Wiki says "ID field (42h, 4Dh)", not "first 2 bytes must be 0x424D".

Categories : C

How to see the bytes of a Python3 object?
Use bin, oct or hex and access the byte using bracket notation: >>> print(hex(se[0])) 0x68 >>> print(hex(se[1])) 0x69 Obviously a cycle will be better: for a_byte in se: print (bin(a_byte))

Categories : Python

why 1x1 size 8bit bmp is 1082 bytes 24 bit is just 58 bytes?
The 8 bit BMP uses a color table, which has 256 entries (one for each byte value) 4 bytes each (3 for RGB and 1 for alpha or just for alignment). (But: read the comment by user763305.) Anyway, have a look at the PNG format, it is usually the easiest format for lossless image file interchange. You can choose between 1-bit grayscale (i.e., B&W) and 8-bit grayscale.

Categories : Image

Java - String of bytes to bytes[]
String b = "[B@64964f8e"; that's not a real string. That's the type and address of your byte array. It's nothing more than a transient reference code, and if the original array was GC'd you wouldn't even have a hope of getting it back with really funky native methods romping through memory.

Categories : Java

Why is a double always 8 bytes and an int always 4 bytes, even if the int has more digits?
These primitive datatypes need to be defined somewhere for you to use them. It is not a flexible container where you can stuff in whatever you want, rather more like a bottle which takes the same space no matter if full or empty. And they also have a maximum they can contain. Read more yourself here.

Categories : Java

Xcode Instrument : Memory Terms Live Bytes and Overall Bytes (Real Memory) confusion
"Live Bytes" means "memory which has been allocated, but not yet deallocated." It's important because it's the most easily graspable measure of "how much memory your app is using." "Overall Bytes" means "all memory which has ever been allocated including memory that has been deallocated." This is less useful, but gives you some idea of "heap churn." Churn leads to fragmentation, and heap fragmentation can be a problem (albeit a pretty obscure one these days.) "Real Memory" is an attempt to distinguish how much physical RAM is in use (as opposed to how many bytes of address space are valid). This is different from "Live Bytes" because "Live Bytes" could include ranges of memory that correspond to memory-mapped files (or shared memory, or window backing stores, or whatever) that are not c

Categories : IOS

Read several bytes, jump over N bytes, and then read several bytes again. how?
To read to a certain point in an array you need to give it the address a1.read(tmp+2, 2) Or you can do a1.read(&tmp[2], 2) // the & operator is the address of operator

Categories : C++

Cocoa code- how to print 1024 bytes of a file in one page and next 1024 bytes in the next page after pressing the next button?
Each call to the next method appends the hex output to the instance variable (?) string. You have to start with an empty string in the next method. Either call [string setString:@""]; at the start of next, or replace the instance variable with a local variable NSMutableString *string = [[NSMutableString alloc]init]; in the next method. Also, as trojanfoe correctly commented, you should not call [textview setString: string]; 1024 times inside the for-loop, but call it once after the loop.

Categories : Objective C

JQuery Replace "Special" Function (like replace(/#[^#]*$/, "") replace(/?[^?]*$/, ""))
They are called regular expressions. Regular expressions are patterns used to match character combinations in strings

Categories : Jquery

Replace DIV inside another DIV with TEXTAREA, edit text and replace back
You can try like this example javascript: $("#edit").live("click",function(){ $(".inputbox").val($("#menu").text()).show(); $("#menu").hide(); $("#save").show(); $(this).hide(); }); $("#save").live("click",function(){ $("#menu").show(); $("#menu b").html($(".inputbox").val()); $(".inputbox").hide(); $("#edit").show(); $(this).hide(); });

Categories : Jquery

Find and replace duplicates in Array, but replace each nth instance with a different string
EDIT Counter and than sorting is simpler: L = ['champ', 'king', 'king', 'mak', 'mak', 'mak'] counts = Counter(L) res = [] for word in sorted(counts.keys()): if counts[word] == 1: res.append(word) else: res.extend(['{}{}'.format(word, index) for index in range(1, counts[word] + 1)]) So this ['champ', 'mak', 'king', 'king', 'mak', 'mak'] also gives: ['champ', 'king1', 'king2', 'mak1', 'mak2', 'mak3']

Categories : Python

Javascript: using String.replace() to replace/remove HTML anchors
All of the anchors are stored in an array (['about','contact'],...), and I need to remove every occurance of a string like href="#whatever" (where whatever is each time something different) so that the result is for this you could do something like this: var tets_array = $("a[href^='#']"); // select all a tags having href attr starting with # Then take the array and modify with what you want.

Categories : Javascript

String replace: multiple replace is not working in JQuery
Use global replace with "g" flag: /reg_ex_here/g or new RegExp(exp, 'g') var string = 'bla bla bla'; string.replace(/bla/g, 'ok'); // -> ok ok ok string.replace(new RegExp('bla', 'g'), 'ok'); // -> ok ok ok In your code: var replace_str = 'options\[team_member\]\['+(current-1)+'\]'; rep_block = block.replace(new RegExp(replace_str, 'g'), replace_with);

Categories : Javascript

Replace double period to single and if 4 or more replace to three
Try fieldval = fieldval.replace( /.{2,}/g, function(val){ return val.length == 2 ? '.' : '...'; } ); Demo: Fiddle

Categories : Javascript

In NotePad++ find and replace, how would I use what I found in my replace?
Enclose it in parentheses in your find. request.POST[("[a-z A-Z _]*")] Then use 1 in your replace. That will return what was captured by the first set of parentheses. (Use 2, 3, etc. if you have multiple capturing groups.

Categories : Regex

How to replace a whitespace before number using Replace method?
That's a job for a positive lookahead assertion: String resultString = subjectString.replaceAll(" (?=\d)", " "); If you meant any kind of whitespace (including tabs, newlines, formfeeds etc.), use \s instead of the simple space I used here.

Categories : Java

How to replace percentage value to replace with some string value in percentage specific 2d horizontal fusion charts
give numbersuffix='%25' to display '%' as suffix sample : http://www.fusioncharts.com/free/docs/Contents/Adv_SpChar_Percent.html

Categories : Misc

Use RegEx with IgnoreCase to replace a word but replace using correct found word case
The following has pretty much what you're looking for using Regex. The only consideration is that it keeps the case for the first character, so if you have an upper case in the middle it doesn't look like it will keep that. Replace Text While Keeping Case Intact In C Sharp

Categories : C#

Getting a swf's bytes from within the swf
My guess is that stage.loaderInfo.bytes contains the uncompressed SWF data. In most SWFs, the first few bytes or so contain a little uncompressed binary data and the rest of the SWF is compressed. You can refer to the spec for more info on that. I would expect that bytes would contain this uncompressed header data followed by the rest of the SWF data, now decompressed. As a sidenote, bytesTotal gives you the compressed length, which is why it shows you the value you expect. One possible way to reconstruct the compressed SWF would just be to compress the part of the data from bytes with the appropriate algorithm, which is actually indicated by the very first byte of the SWF. What do you need the actual data for?

Categories : Actionscript

Two bytes into one
Are you sure that it's alphaData[x2]=lo*17; alphaData[x2+1]=hi*17; and not alphaData[x2]=lo*16; alphaData[x2+1]=hi*16; In any case, to generate the values that work with the decoding function you have posted, you just have to reverse the operations. So multiplying by 17 becomes dividing by 17 and the shifts and masks get reordered to look like this: for(int x=0,w=0;x < alphaData.size();x+=2,w++) { unsigned char alpha1 = alphaData[x] / 17; unsigned char alpha2 = alphaData[x+1] / 17; Assert(alpha1 < 16 && alpha2 < 16); alphaFinal[w]=(alpha2 << 4) | alpha1; }

Categories : C++

How to return bytes to C#/.net from C?
Your C API is writing unsigned integers. I would typically expect this to be mapped as: [DllImport(PlatformConstants.DllName, CallingConvention=CallingConvention.Cdecl)] static extern void alve_ripemd320__finish(IntPtr instance_space, uint[] hash); public uint[] Finish() { uint[] result = new uint[10]; alve_ripemd320__finish (c_instance, ref result); return result; } There are three main changes here: I switched the calling convention to Cdecl. This is the standard for the C++ compiler (unless you're explicitly switching to stdcall in DLL_PUBLIC). I changed to match your C API, which uses 32 bit unsigned integers instead of bytes. You should be able to switch back to byte[] if you choose, however. You shouldn't need to pass by ref. This would typically be the equivelent

Categories : C#

How many bytes in a map in MATLAB?
There is a script to do this for any struct over at matlab central, which I believe will also work for a map. To implement it yourself, you need to recurse over the content of the map and subsequently over all the fields in the structs or cells it may contain to determine the sizes.

Categories : Matlab

Working with bytes in VB.NET
I got the answer, thanks to user x4rf41 Maybe need some fixes but its what I was looking for. This is the code: Private Sub thread_lectura_tarjeta1() Dim RXByte As Byte 'byte recived Dim RXPacket As List(Of Byte) = New List(Of Byte) 'each reading has 4 bytes Dim lectura As Long = 0 'is the FINAL data Dim COMPort As SerialPort = ensayo.get_digitalizadores(0).get_puerto_com Dim chk_signo As Byte = 0 While (True) lectura = 0 Do 'each package starts with a byte > 127, because is the only byte that its first bit is 0 RXByte = COMPort.ReadByte Loop Until (RXByte > 127) RXByte = RXByte And 127 RXPacket.Insert(0, RXByte) RXByte = COMPort.ReadByte

Categories : Vb.Net

how could I get the first 4 bytes with xsocket
At Interface INonBlockingConnection in the XSocket documentation, it suggests that you use ByteBuffer readByteBuffer to read larger amounts of data. Given that your whole company has to go through this gateway, processing data in blocks would seem more appropriate. Your approach limits sends the length as a sequence of ASCII digits. You would be better placed to use the readInt() method to retrieve a binary length from the stream.

Categories : Misc

How to Replace CSV String in LINQ Query , Wanted to Replace CSV with NewLine in LINQ
Html does not recognize new lines as actual line breaks when rendered. Instead try this: var query = (from r in objEntities.Student select new { FullName = r.FullName.Replace(",", "<br />") }).ToList();

Categories : String

VB Raw TCP Read only reading first 5 bytes
With the code you posted, the Response.Data will never have more than 5 bytes because that is the largest number that a call to stm.Read will ever assign to numRead. I think you want ofst instead (and you will may need to increment it after reading the stream instead of before).

Categories : Vb.Net

Can ffmpeg be used to output to bytes
Yes, it is. You gotta learn how to use the other protocols FFmpeg has. Input/output to a file is just a particular protocol... but you can output, for example, to a socket, to a FTP/HTTP, and so on... It's very easy for anyone to create a new protocol (in C, of course) and register it with FFmpeg. I don't think FFmpeg has a built-in solution to write to a buffer, but for sure it's possible. I've done this once.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.