Advertisement
Guest User

Untitled

a guest
Mar 21st, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.21 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <iconv.h>
  6.  
  7. void print_tripcode (void *job, char *password, char *tripcode)
  8. {
  9.     iconv_t ic = iconv_open ("UTF8", "SHIFT_JIS");
  10.     char *utf8_password_orig, *utf8_password;
  11.     size_t sjis_pass_len = strlen (password);
  12.     size_t utf8_pass_len = sjis_pass_len * 2;
  13.    
  14.     utf8_password_orig = utf8_password = malloc (20);
  15.     memset (utf8_password_orig, 0, 20);
  16.    
  17.     if (iconv (ic, &password, &sjis_pass_len, &utf8_password, &utf8_pass_len) == -1)
  18.     {
  19.         printf ("iconv could not convert password. Error is: %s\n", strerror(errno));
  20.         iconv_close (ic);
  21.         free (utf8_password_orig);
  22.     }
  23.    
  24.     printf ("%s = %s\n", utf8_password_orig, tripcode);
  25.    
  26.     iconv_close (ic);
  27.     free (utf8_password_orig);
  28. }
  29.  
  30. int main (void)
  31. {
  32.     char *sjis_string = malloc (9); // ]髀_]違P
  33.     sjis_string[0] = 0x5D; // this is the Shift-Jis representation of the string on the previous line
  34.     sjis_string[1] = 0xE9;
  35.     sjis_string[2] = 0x8F;
  36.     sjis_string[3] = 0x5F;
  37.     sjis_string[4] = 0x5D;
  38.     sjis_string[5] = 0x88;
  39.     sjis_string[6] = 0xEL;
  40.     sjis_string[7] = 0x50;
  41.     sjis_string[8] = 0x00;
  42.    
  43.     char *tripcode = "Win/gentoo";
  44.    
  45.     print_tripcode (NULL, sjis_string, tripcode);
  46.    
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement