Sponsored Content
Top Forums Programming converting character string to hex string Post 302089720 by Corona688 on Wednesday 20th of September 2006 12:58:48 PM
Old 09-20-2006
Your string is 16-bit unicode. How are you reading it??

Once you've inputted a 16-bit unicode string, you can print it like this:
Code:
#include <stdio.h>
#include <string.h>

int main()
{
  int n;
  unsigned short int ustr[]=
    { 0xD7A5, 0xEF41, 0x00C5, 0x0100, 0x67EF, 0xDBFD, 0x0000};

  for(n=0; ustr[n] != 0x0000; n++)
    printf("%04x",ustr[n]);

  printf("\n");
  return(0);
}

[edit] I'm glad my first example worked but I have not a clue how it managed that feat. Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

2. Shell Programming and Scripting

Match hex value in string (Perl)

I am trying to match a character return from a website so that I can replace it. It is the '...' character (didnt even know it existed initially). The character apparently has the hex value of 2026, but in the script, attempting to substitute regular 3 periods is not working. What am I... (2 Replies)
Discussion started by: Guyverix
2 Replies

3. Programming

Hex string conversion?

Hello all. I need help... How can I cenvert this 42ec93df826c804ea531c56594db453d54daad4b to normal text? What convertor I have to use? Thanks. (12 Replies)
Discussion started by: escudo
12 Replies

4. Programming

how to use hex escape char with string in C?

I want it to ouput "abcd", but it dosen't. 1 #include<stdio.h> 2 int main() 3 { 4 printf("a\x62cd"); 5 } 6 gcc alarm.c -o alarm alarm.c: In function 'main': alarm.c:4:9: warning: hex escape sequence out of range It seems that the complier joint "cd" as part of... (8 Replies)
Discussion started by: vistastar
8 Replies

5. Shell Programming and Scripting

Converting parts of a string to "Hex"

Hi Guys, writing a small shell script, i need to convert parts of a string to "Hex". The problem is that it is not the full string that needs to be converted. I think it's best to show an example: $astring = "xxxxxx ABC+10+##########+DEF xxxx" This is only an example to show how the... (9 Replies)
Discussion started by: HansHansen
9 Replies

6. Shell Programming and Scripting

String to HEX conversion in UNIX

i have this below string which i need to convert it to HEX. i have already tried it but it showing extra few things on it.. let me show what i have done and what is the output i am getting and what is the desired output the input string is "!\"\"\"\"\"\"\"!\"\"\"\"\"\"\"" which is... (4 Replies)
Discussion started by: vivek d r
4 Replies

7. Shell Programming and Scripting

Swapping a string of numbers between higher and lower order values(HEX)

I have this below string in a variable cutString=21222222222222222122222222222222 this string is nothing but hex values depicted as below 21:22:22:22:22:22:22:22:21:22:22:22:22:22:22:22 so what i want to achieve is swap the lower order with higher order values in the... (3 Replies)
Discussion started by: vivek d r
3 Replies

8. Shell Programming and Scripting

sed searches a character string for a specified delimiter character, and returns a leading or traili

Hi, Anyone can help using SED searches a character string for a specified delimiter character, and returns a leading or trailing space/blank. Text file : "1"|"ExternalClassDEA519CF5"|"Art1" "2"|"ExternalClass563EA516C"|"Art3" "3"|"ExternalClass305ED16B8"|"Art9" ... ... ... (2 Replies)
Discussion started by: fspalero
2 Replies

9. Shell Programming and Scripting

Find and increment value in string of hex

I have a long string of hex (from ASN.1 data) where I need to find and change a particular hex value only and increment it. The hex pairs either side (84 and a7) of the value to increment will remain constant. i.e. "84 <length> <value_to_increment> a7" starting with 00. So end result: ... (11 Replies)
Discussion started by: securegooner
11 Replies

10. UNIX for Beginners Questions & Answers

Using sed to split hex string

Hi, I'm looking to split the following hex string into rows of four elements. I've tried the following but it doesn't seem to work. How can I tell sed to match based on a pair of number(s) and letter(s), and add a newline every 4 pairs? In addition, I need to add another newline after every... (5 Replies)
Discussion started by: sand1234
5 Replies
ustr(1) 						    Ustr String Library, tools							   ustr(1)

NAME
ustr-import - ustr string library import tool SYNOPSIS
ustr-import [--32|--64] [-d][d] [-c] [-b x] [-e 1|0] [-s 1|0] section DESCRIPTION
This tool lets you use the Ustr string library without incuring dependancies on the library itself, so API/ABI compatability is 100% (nothing changes unless you do it) and installing your application doesn't require the library to be pre-installed. OPTIONS
--32 If you installed with multilib, this runs the 32 bit varient (and installs the variable multilib build code as ustr-conf.h). --64 If you installed with multilib, this runs the 64 bit varient (and installs the variable multilib build code as ustr-conf.h). -d Turn debugging on, USTR_ASSERT() now runs code etc. -d Turn extra debugging on, including End of String (EOS) markers that takeup space. Note that you can do -dd to add both at once. -c Use C files, this requires that you alter the build system to compile the C files and link them into your application. The default is to just provide headers that you can just include. -b Specify the default reference count byte size: 0, 1, 2 or 4 (or 8 on 64 bit platforms). Note that 2 bytes is the minimum if you have explicit size storage. -e Specify the default exact sized allocations flag, without this flag allocations are rounded up to the neared half power of two. -s Specify the default explicit size storage flag, without this flag allocations have an implicit size based on their length with it a size value is stored with the string (thus taking significantly larger space for small strings, but this doesn't require reallocating the string when growing and shrinking the string). Note that turning this on also increases the minimum sizes for length and reference count storage. SECTIONS
all All of the following sections are included. b Working with binary numbers in NBO format. cmp Comparing, strcmp() for Ustr's, although the Ustr versions are safer and much faster. cntl Control options dynamically. fmt Formatted output, sprintf() for Ustr's. gdb Copy just the .gdbinit file to the local dir. io Input Output. ins Inserting data. main The core functions, including strcat(), strdup() and delete for Ustr's. Always safer and often much faster. parse Parsing integers, Ie. Nice versions of strtol(). pool A bundled memory pool API, to use with the ustrp functions. replace Replacing all occurances of data. sc Shortcut functions for Ustr's. set Setting data, strcpy() for Ustr's. split Slit the data, strtok() / strsep() for Ustr's. spn Spanning, strspn() / strcspn() for Ustr's. srch Searching, strchr() / strrchr() / strstr() for Ustr's, although the Ustr versions are safer and much faster. sub Substituting data. utf8 Working with UTF8. FILES
/ustr/include/ustr-conf.h /ustr/include/ustr-conf-debug.h In multilib. this is the header to choose the correct conf.h header based on the byte size. /ustr/include/ustr*.h The default "extern" header files. /usr/share/ustr-*/ustr-*-internal.h Internal functions, used the implement the public interfaces. /usr/share/ustr-*/ustr-*-code.h The code behind the public interfaces. /usr/share/ustr-*/ustr-*-code.c The C files, which use the code header files to create objects. /usr/share/ustr-*/.gdbinit The GDB init file containing macros to help inspect Ustr's in the debugger. SEE ALSO
ustr(3),ustr_const(3) ustr-import 1.0.4 03-Aug-2007 ustr(1)
All times are GMT -4. The time now is 04:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy