/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/languages/C/Samples/iconv/iconv.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <iconv.h>
 
3
 
 
4
main()
 
5
{
 
6
        char *a=malloc(255);
 
7
        char *b=malloc(255);
 
8
        size_t as,bs=255;       /* as - doesn't understand end of string,
 
9
                                must be exact number */
 
10
        size_t length;
 
11
        iconv_t ic;
 
12
 
 
13
        strcpy(a,"He��!");
 
14
        length=strlen(a);as=length;
 
15
        ic=iconv_open("KOI8-R","CP1251");
 
16
        printf("%li %li\n",ic,(iconv_t)(-1));
 
17
 
 
18
        printf("Pointers befor: %p %p\n",a,b);
 
19
        printf("as bs before: %lu %lu\n",as,bs);
 
20
        printf("String before: %s\n",a);
 
21
        printf("Characters converted in non reversible way: %lu\n",iconv(ic,&a,&as,&b,&bs));
 
22
        printf("Pointers after: %p %p\n",a,b);
 
23
        printf("as bs before: %lu %lu\n",as,bs);
 
24
        printf("Strings after: %s %s\n",a-length,b-length);
 
25
        
 
26
        iconv_close(ic);
 
27
        
 
28
}
 
 
b'\\ No newline at end of file'