[Solved] How to count the number of characters in a line in a csv file

I suggest you to read the javadoc of String.split. I think that you misunderstood the concept when you did this: String[] f=line.split(“,”); a[count]=Integer.parseInt(f[2]); //–> java.lang.NumberFormatException here! Avoid using ‘magic’ numbers in your code like int[] a = new int[24];. Why 24? Well, here comes a version that do what you want to do. Maybe it … Read more

[Solved] Convert binary, octal, decimal and hexadecimal values between each other in BASH / Shell [duplicate]

Convert binary, octal, decimal and hexadecimal values between each other in BASH with bc and printf Some relevant Q&A: Understand “ibase” and “obase” in case of conversions with bc? TL;DR: ibase and obase params order matters, but not always. Hex values must be in UPPERCASE. Convert a character from and to its decimal, binary, octal, … Read more

[Solved] Invert 7th bit of hex string C++ [duplicate]

#include <stdio.h> void flipme(char *buf, const char *inBuf) { int x; sscanf(inBuf, “%x”, &x); x ^= 1 << 17; sprintf(buf, “%06X”, x); } int main(void) { char buf[16]; flipme(buf, “002A05”); printf(“002A05->%s\n”, buf); flipme(buf, “ABCDEF”); printf(“ABCDEF->%s\n”, buf); } Output: 002A05->022A05 ABCDEF->A9CDEF You wrote: I tried converting hex string to integer via strtol, but that function strip … Read more

[Solved] How to inverse an integer in C?

Technically, no. But why are you using htons? It changes the endianess of a 16 bit datum to big-endian (that is, network byte order). First is your variable not 16 bit but 32 bit, so uint16_t acc = 0xBBD1 would be more appropriate. Second, as your on a little-endian machine, the bytes are exchanged, hence … Read more

[Solved] How can I find the language of this code and how can I find the tool to convert this code to text or HTML [closed]

They seem to be HTML entities, but they are not complete, they should end with ‘;’ So the code should read: &#1112;&#965;&#1109;t The characters you see are: &amp;#1112; CYRILLIC SMALL LETTER JE &amp;#965; GREEK SMALL YPSILON &amp;#1109; CYRILLIC SMALL LETTER DZE t a normal t In your browser it look almost like ‘just’ For a … Read more

[Solved] How to convert decimal into octal in objective c

You have to initialize a new NSString object using the right format specifier. Like : int i = 9; NSString *octalString = [NSString stringWithFormat:@”%o”, i]; // %O works too. This will create an autoreleased NSString object containing octal string representation of i. In case you start from a NSString containing a decimal number representation, you … Read more

[Solved] Get unreadable string from GPS tracker

Its really some binary information and If you have clearly read out the product manual then it says formation of this binaries. Converting the data to hex will give something like this.. 24-41-20-20-67-72-51-30-35-41-68-40-91-29-3F-3F-3F-FF-FF-FB-FF-FF-3F-3F- And then you need to refer the manual for exact meaning of these hex numbers ex–(in some chinese devices) 2 bytes(24), stand … Read more

[Solved] How to put a hex value into a 24 bit struct

If you have control of your input format, i.e. you can guarantee it will always be something like 0xabc, then you can try: const char input[] = “0xabc”; uint32_t tmp; sscanf(input, “0x%x”, &tmp); struct cmd cmdid; cmdid.a = (tmp & 0xFF0000U) >> 16; cmdid.b = (tmp & 0xFF00U) >> 8; cmdid.c = (tmp & 0xFFU); … Read more

[Solved] Convert Ascii “1” to hex thats non printable and cannot be seen on network traffic [closed]

Either use real encryption and decryption between your source and destination (implementation will vary depending on how you are sending the data) or just obfuscate a bit by adding a known value to the hex that is ‘only’ known by the source and destination (probably best to modulo this by 127) – essentially this is … Read more