begin process at 2010 03 19 23:33:57
  Trouver un code source :
 
dans
 
Accueil > Forum > 

C

 > 

Divers

 > 

Débutant(e)

 > 

code ascii


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

code ascii

dimanche 11 novembre 2007 à 03:05:17 | code ascii

tasken2

bonjour à tous  et merci d'avoir cliquez sur moi .
Alors voila j'ai un probleme pour récuperer la valeur du code ascii dun caractere speciaux
mais le resultat n'est pas celui que j'attends quelqu un peut mexpliquer pourquoi ?
je voudrais qu'il maffiche le code ascii de Ö et il maffiche -99 ..
je crois que c un probleme de charset siouplait alaide !
voici mon programe :
MAIN.c


#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "charset.h"


int main(int argc,char* argv[],int iNbArg,char ** capArg)
{
    // Chaîne Iso8859-1
    printf("declaration des variable\n");
    PAUSE();
    long i = 1;
    char password[]=("klbmfgh");
    long j=0;
    long k=0;
    long pwdec[]={0};
    char url[]="";
    char verify[]="";
    char *decode[17]={0};
    int caracActuel= 0;
    char copycaeascii[100]={0};
    char caSrc[]="ÖØÄÚÞÌ×îè×ÏÞÓÝèòØ";/* var unknown */
    int iStrLen = strlen(caSrc),ret;
    FILE *unknown=NULL;

    printf("Transformation du contenu de la variable unknown en ASCII\n");
    PAUSE();
    char caEAscii[iStrLen];
    ret = iso8859ToEascii(caSrc,iStrLen,caEAscii,iStrLen);
    caEAscii[ret] = 0;
    printf("Extended Ascii: %s\n",caEAscii);/* EXTENDED ASCII */
    strcpy(copycaeascii,caEAscii);
    printf("var unknown = %s\n",copycaeascii); /* var unknown = copycaeascii */
    PAUSE();
    for (k=0;k < strlen(caSrc); k++)
    {


    }

PAUSE();

printf("la valeur de decode est : %s\n",decode);

 if (strcmp(copycaeascii,caEAscii) == 0)
 {
     printf("la copy de unknow est identique a la valeur de unknown soit :\n%c\n",copycaeascii[1]);
     PAUSE();
     printf("le code ascii de %c est %d\n",copycaeascii[1],copycaeascii[1]);
     PAUSE();
 }
 else
 {
 printf("les chaine ne sont pas identique\n");
 }
    system("pause");
    return 0;
}


CHARSET.h :



#ifndef UNICODE
#define UNICODE
#define wchar               unsigned short // Unicode is encoded in 16 bits

#define DEST_TOO_SMALL        0
#define UTF8_BAD_STRING      -1
#define INCOMPATIBLE_UNICODE -1
#define INCOMPATIBLE_EASCII  -1
#define INCOMPATIBLE_ISO8859 -1
#define PAUSE() system("PAUSE");\
printf("\n\n");
#define TAILLEMAX 100000

char* strcpy(char* copieDeLaChaine, const char* chaineACopier);

int strcmp(const char* chaine1, const char* chaine2);
unsigned int easciiToIso8859(const char * capSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen);
unsigned int iso8859ToUnicode(const char * capSrc,unsigned int iSrcLen,wchar * wcapDest,unsigned int iDestLen);
unsigned int unicodeToUtf8(const wchar * wcapSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen);
unsigned int utf8ToUnicode(const char * capSrc,unsigned int iSrcLen,wchar * wcapDest,unsigned int iDestLen);
unsigned int unicodeToIso8859(const wchar * wcapSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen);
unsigned int iso8859ToEascii(const char * capSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen);
#endif



CHARSET.C




/**
 * Functions to Convert beetween different charset
 * author Julien Folly
 * version 1.0
 */

#include "charset.h"

#define ASCII               0x7f    // 7 Bits
#define ISO_8859            0xff    // 8 Bits

#define UTF8_MAX_IN_1       0x7f     //  7 bits (2^7-1)
#define UTF8_MAX_IN_2       0x7ff    // 11 bits (2^11-1)
#define UTF8_MAX_IN_3       0xffff   // 16 bits (2^16-1)

#define UTF8_1ST_OF_1       0     // 0xxx xxxx
#define UTF8_1ST_OF_2       0xc0  // 110x xxxx
#define UTF8_1ST_OF_3       0xe0  // 1110 xxxx
#define UTF8_TRAIL          0x80  // 10xx xxxx

/**
 * Convert from Extended ascii to ISO 8859-1
 * Return iSrcLen, DEST_TOO_SMALL if the destination is too small, or
 * INCOMPATIBLE_EASCII if it's impossible to convert from eascii to ios8835
 * The iDestLen should be equal to iSrcLen
 *
 * capSrc    ->    Pointer to the string to convert
 * iSrcLen   ->    Number of character in capSrc
 * capDest   ->    Pointer to an allocated memory area for the converted string
 * iDestLen  ->    Size of the allocated memory area
 */
unsigned int easciiToIso8859(const char * capSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen){
    if(iDestLen < iSrcLen) return DEST_TOO_SMALL;
    unsigned int i,ret = iSrcLen;

    for(i = 0 ; i<iSrcLen ; ++i){
        switch((unsigned char)capSrc[i]){
            case 0x80: capDest[i] = 0xC7; break;
            case 0x81: capDest[i] = 0xFC; break;
            case 0x82: capDest[i] = 0xE9; break;
            case 0x83: capDest[i] = 0xE2; break;
            case 0x84: capDest[i] = 0xE4; break;
            case 0x85: capDest[i] = 0xE0; break;
            case 0x86: capDest[i] = 0xE5; break;
            case 0x87: capDest[i] = 0xE7; break;
            case 0x88: capDest[i] = 0xEA; break;
            case 0x89: capDest[i] = 0xEB; break;
            case 0x8A: capDest[i] = 0xE8; break;
            case 0x8B: capDest[i] = 0xEF; break;
            case 0x8C: capDest[i] = 0xEE; break;
            case 0x8D: capDest[i] = 0xEC; break;
            case 0x8E: capDest[i] = 0xC4; break;
            case 0x8F: capDest[i] = 0xC5; break;
            case 0x90: capDest[i] = 0xC9; break;
            case 0x91: capDest[i] = 0xE6; break;
            case 0x92: capDest[i] = 0xC6; break;
            case 0x93: capDest[i] = 0xF4; break;
            case 0x94: capDest[i] = 0xF6; break;
            case 0x95: capDest[i] = 0xF2; break;
            case 0x96: capDest[i] = 0xFB; break;
            case 0x97: capDest[i] = 0xF9; break;
            case 0x98: capDest[i] = 0xFF; break;
            case 0x99: capDest[i] = 0xD6; break;
            case 0x9A: capDest[i] = 0xDC; break;
            case 0x9B: capDest[i] = 0xF8; break;
            case 0x9C: capDest[i] = 0xA3; break;
            case 0x9D: capDest[i] = 0xD8; break;
            case 0x9E: capDest[i] = 0xD7; break;
            case 0xA0: capDest[i] = 0xE1; break;
            case 0xA1: capDest[i] = 0xED; break;
            case 0xA2: capDest[i] = 0xF3; break;
            case 0xA3: capDest[i] = 0xFA; break;
            case 0xA4: capDest[i] = 0xF1; break;
            case 0xA5: capDest[i] = 0xD1; break;
            case 0xA6: capDest[i] = 0xAA; break;
            case 0xA7: capDest[i] = 0xBA; break;
            case 0xA8: capDest[i] = 0xBF; break;
            case 0xA9: capDest[i] = 0xAE; break;
            case 0xAA: capDest[i] = 0xAC; break;
            case 0xAB: capDest[i] = 0xBD; break;
            case 0xAC: capDest[i] = 0xBC; break;
            case 0xAD: capDest[i] = 0xA1; break;
            case 0xAE: capDest[i] = 0xAB; break;
            case 0xAF: capDest[i] = 0xBB; break;
            case 0xB5: capDest[i] = 0xC1; break;
            case 0xB6: capDest[i] = 0xC2; break;
            case 0xB7: capDest[i] = 0xC0; break;
            case 0xB8: capDest[i] = 0xA9; break;
            case 0xBD: capDest[i] = 0xA2; break;
            case 0xBE: capDest[i] = 0xA5; break;
            case 0xC6: capDest[i] = 0xE3; break;
            case 0xC7: capDest[i] = 0xC3; break;
            case 0xCF: capDest[i] = 0xA4; break;
            case 0xD0: capDest[i] = 0xF0; break;
            case 0xD1: capDest[i] = 0xD0; break;
            case 0xD2: capDest[i] = 0xCA; break;
            case 0xD3: capDest[i] = 0xCB; break;
            case 0xD4: capDest[i] = 0xC8; break;
            case 0xD6: capDest[i] = 0xCD; break;
            case 0xD7: capDest[i] = 0xCE; break;
            case 0xD8: capDest[i] = 0xCF; break;
            case 0xDD: capDest[i] = 0xA6; break;
            case 0xDE: capDest[i] = 0xCC; break;
            case 0xE0: capDest[i] = 0xD3; break;
            case 0xE1: capDest[i] = 0xDF; break;
            case 0xE2: capDest[i] = 0xD4; break;
            case 0xE3: capDest[i] = 0xD2; break;
            case 0xE4: capDest[i] = 0xF5; break;
            case 0xE5: capDest[i] = 0xD5; break;
            case 0xE6: capDest[i] = 0xB5; break;
            case 0xE7: capDest[i] = 0xDE; break;
            case 0xE8: capDest[i] = 0xFE; break;
            case 0xE9: capDest[i] = 0xDA; break;
            case 0xEA: capDest[i] = 0xDB; break;
            case 0xEB: capDest[i] = 0xD9; break;
            case 0xEC: capDest[i] = 0xFD; break;
            case 0xED: capDest[i] = 0xDD; break;
            case 0xEE: capDest[i] = 0xAF; break;
            case 0xEF: capDest[i] = 0xB4; break;
            case 0xF0: capDest[i] = 0xAD; break;
            case 0xF1: capDest[i] = 0xB1; break;
            case 0xF3: capDest[i] = 0xBE; break;
            case 0xF4: capDest[i] = 0xB6; break;
            case 0xF5: capDest[i] = 0xA7; break;
            case 0xF6: capDest[i] = 0xF7; break;
            case 0xF7: capDest[i] = 0xB8; break;
            case 0xF8: capDest[i] = 0xB0; break;
            case 0xF9: capDest[i] = 0xA8; break;
            case 0xFA: capDest[i] = 0xB7; break;
            case 0xFB: capDest[i] = 0xB9; break;
            case 0xFC: capDest[i] = 0xB3; break;
            case 0xFD: capDest[i] = 0xB2; break;

            default:
                if((unsigned char)capSrc[i] > ASCII) ret = INCOMPATIBLE_EASCII;
                capDest[i] = capSrc[i];
        }
    }
    return ret;
}

/**
 * Convert from ISO 8859-1 to Unicode
 * Return iSrcLen or DEST_TOO_SMALL if the destination is too small
 * The iDestLen should be equal to iSrcLen
 *
 * capSrc    ->    Pointer to the string to convert
 * iSrcLen   ->    Number of character in capSrc
 * wcapDest  ->    Pointer to an allocated memory area for the converted string
 * iDestLen  ->    Size of the allocated memory area
 */
unsigned int iso8859ToUnicode(const char * capSrc,unsigned int iSrcLen,wchar * wcapDest,unsigned int iDestLen){
    if(iDestLen < iSrcLen) return DEST_TOO_SMALL;
    unsigned int i;

    for(i = 0 ; i<iSrcLen ; ++i)
        wcapDest[i] = capSrc[i] & ISO_8859;
    return iSrcLen;
}

/**
 * Convert from unicode to UTF8
 * Return the number of UTF8 byte or DEST_TOO_SMALL if the destination is too small
 * The iDestLen should be at maximum 3 * iSrcLen
 *
 * wcapSrc   ->    Pointer to the string to convert
 * iSrcLen   ->    Number of character in capSrc
 * capDest   ->    Pointer to an allocated memory area for the converted string
 * iDestLen  ->    Size of the allocated memory area
 */
unsigned int unicodeToUtf8(const wchar * wcapSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen){
    if(iDestLen == 0) return DEST_TOO_SMALL;
    unsigned int iNbUTF8 = 0;
    unsigned int i;

    for(i = 0 ; i<iSrcLen ; ++i){

        // Found 1 bits sequence (ASCII)
        if(wcapSrc[i] <= UTF8_MAX_IN_1){
            capDest[iNbUTF8++] = wcapSrc[i];
            if(iNbUTF8 > iDestLen) return DEST_TOO_SMALL;
        }else

        // Found 2 bits sequence
        if(wcapSrc[i] <= UTF8_MAX_IN_2){
            capDest[iNbUTF8++] = UTF8_1ST_OF_2 | (wcapSrc[i] >> 6  );
            if(iNbUTF8 > iDestLen) return DEST_TOO_SMALL;

            capDest[iNbUTF8++] = UTF8_TRAIL      | (wcapSrc[i] & 0x3F);
            if(iNbUTF8 > iDestLen) return DEST_TOO_SMALL;
        }else

        // Found 3 bits sequence
        /* if(wcapSrc[i] <= UTF8_MAX_IN_3) */{
            capDest[iNbUTF8++] = UTF8_1ST_OF_3 | (wcapSrc[i] >> 12);
            if(iNbUTF8 > iDestLen) return DEST_TOO_SMALL;

            capDest[iNbUTF8++] = UTF8_TRAIL        | ((wcapSrc[i] >> 6) & 0x3F);
            if(iNbUTF8 > iDestLen) return DEST_TOO_SMALL;

            capDest[iNbUTF8++] = UTF8_TRAIL        | (wcapSrc[i] & 0x3F);
            if(iNbUTF8 > iDestLen) return DEST_TOO_SMALL;
        }
    }
    return iNbUTF8;
}

/**
 * Convert from UTF8 to unicode
 * Return the number of character, DEST_TOO_SMALL if the destination is too small,
 * or UTF8_BAD_STRING if the UTF8 String is invalid
 * The iDestLen should be equal to iSrcLen
 *
 * capSrc    ->    Pointer to the string to convert
 * iSrcLen   ->    Number of byte in capSrc
 * wcapDest  ->    Pointer to an allocated memory area for the converted string
 * iDestLen  ->    Size of the allocated memory area
 */
unsigned int utf8ToUnicode(const char * capSrc,unsigned int iSrcLen,wchar * wcapDest,unsigned int iDestLen){
    if(iDestLen == 0) return DEST_TOO_SMALL;
    unsigned int iNbUnicode = 0;
    unsigned int i;

    for(i = 0 ; i<iSrcLen ; ++i){

        // Found 3 bits sequence
        if((unsigned char)capSrc[i] >= UTF8_1ST_OF_3){
            if(i+2 >= iSrcLen) return UTF8_BAD_STRING;

            // First 8 bits
            wcapDest[iNbUnicode  ]  = ((capSrc[  i] << 4)               ) <<8;
            wcapDest[iNbUnicode  ] |= ((capSrc[++i] >> 2) & 0xf         ) <<8;

            // Last 8 bits
            wcapDest[iNbUnicode  ] |= (capSrc[  i] & 0x3) << 6;
            wcapDest[iNbUnicode++] |=  capSrc[++i] & 0x3F;

            if(iNbUnicode > iDestLen) return DEST_TOO_SMALL;
        }else

        // Found 2 bits sequence
        if((unsigned char)capSrc[i] >= UTF8_1ST_OF_2){
            if(i+1 >= iSrcLen) return UTF8_BAD_STRING;
            // First 8 bits
            wcapDest[iNbUnicode  ]   =  ((capSrc[  i] >> 2 ) & 0x7      ) <<8;

            // Last 8 bits
            wcapDest[iNbUnicode  ]  |= (capSrc[  i] & 0x3) << 6;
            wcapDest[iNbUnicode++]  |=  capSrc[++i] & 0x3F;

            if(iNbUnicode > iDestLen) return DEST_TOO_SMALL;
        }else

        // Found 1 bits sequence (ASCII)
        /* if((unsigned char)capSrc[i] >= UTF8_1ST_OF_1) */{
            wcapDest[iNbUnicode++] = capSrc[i];
            if(iNbUnicode > iDestLen) return DEST_TOO_SMALL;
        }
    }
    return iNbUnicode;
}

/**
 * Convert from Unicode to ISO 8859-1
 * Return iSrcLen, DEST_TOO_SMALL if the destination is too small, or
 * INCOMPATIBLE_UNICODE if it's impossible to convert from unicode to ios8835
 * The iDestLen should be equal to iSrcLen
 *
 * wcapSrc   ->    Pointer to the string to convert
 * iSrcLen   ->    Number of character in capSrc
 * capDest   ->    Pointer to an allocated memory area for the converted string
 * iDestLen  ->    Size of the allocated memory area
 */
unsigned int unicodeToIso8859(const wchar * wcapSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen){
    if(iDestLen < iSrcLen) return DEST_TOO_SMALL;
    unsigned int i,ret = iSrcLen;

    for(i = 0 ; i<iSrcLen ; ++i){
        if(wcapSrc[i] >> 8 > 0) ret = INCOMPATIBLE_UNICODE;
        capDest[i] = wcapSrc[i];
    }
    return ret;
}

/**
 * Convert from  ISO 8859-1 to Extended ascii
 * Return iSrcLen, DEST_TOO_SMALL if the destination is too small, or
 * INCOMPATIBLE_ISO8859 if it's impossible to convert from ios8835 to eascii
 * The iDestLen should be equal to iSrcLen
 *
 * capSrc    ->    Pointer to the string to convert
 * iSrcLen   ->    Number of character in capSrc
 * capDest   ->    Pointer to an allocated memory area for the converted string
 * iDestLen  ->    Size of the allocated memory area
 */
unsigned int iso8859ToEascii(const char * capSrc,unsigned int iSrcLen,char * capDest,unsigned int iDestLen){
    if(iDestLen < iSrcLen) return DEST_TOO_SMALL;
    unsigned int i,ret = iSrcLen;

    for(i = 0 ; i<iSrcLen ; ++i){
        switch((unsigned char)capSrc[i]){
            case 0xA1: capDest[i] = 0xAD; break;
            case 0xA2: capDest[i] = 0xBD; break;
            case 0xA3: capDest[i] = 0x9C; break;
            case 0xA4: capDest[i] = 0xCF; break;
            case 0xA5: capDest[i] = 0xBE; break;
            case 0xA6: capDest[i] = 0xDD; break;
            case 0xA7: capDest[i] = 0xF5; break;
            case 0xA8: capDest[i] = 0xF9; break;
            case 0xA9: capDest[i] = 0xB8; break;
            case 0xAA: capDest[i] = 0xA6; break;
            case 0xAB: capDest[i] = 0xAE; break;
            case 0xAC: capDest[i] = 0xAA; break;
            case 0xAD: capDest[i] = 0xF0; break;
            case 0xAE: capDest[i] = 0xA9; break;
            case 0xAF: capDest[i] = 0xEE; break;
            case 0xB0: capDest[i] = 0xF8; break;
            case 0xB1: capDest[i] = 0xF1; break;
            case 0xB2: capDest[i] = 0xFD; break;
            case 0xB3: capDest[i] = 0xFC; break;
            case 0xB4: capDest[i] = 0xEF; break;
            case 0xB5: capDest[i] = 0xE6; break;
            case 0xB6: capDest[i] = 0xF4; break;
            case 0xB7: capDest[i] = 0xFA; break;
            case 0xB8: capDest[i] = 0xF7; break;
            case 0xB9: capDest[i] = 0xFB; break;
            case 0xBA: capDest[i] = 0xA7; break;
            case 0xBB: capDest[i] = 0xAF; break;
            case 0xBC: capDest[i] = 0xAC; break;
            case 0xBD: capDest[i] = 0xAB; break;
            case 0xBE: capDest[i] = 0xF3; break;
            case 0xBF: capDest[i] = 0xA8; break;
            case 0xC0: capDest[i] = 0xB7; break;
            case 0xC1: capDest[i] = 0xB5; break;
            case 0xC2: capDest[i] = 0xB6; break;
            case 0xC3: capDest[i] = 0xC7; break;
            case 0xC4: capDest[i] = 0x8E; break;
            case 0xC5: capDest[i] = 0x8F; break;
            case 0xC6: capDest[i] = 0x92; break;
            case 0xC7: capDest[i] = 0x80; break;
            case 0xC8: capDest[i] = 0xD4; break;
            case 0xC9: capDest[i] = 0x90; break;
            case 0xCA: capDest[i] = 0xD2; break;
            case 0xCB: capDest[i] = 0xD3; break;
            case 0xCC: capDest[i] = 0xDE; break;
            case 0xCD: capDest[i] = 0xD6; break;
            case 0xCE: capDest[i] = 0xD7; break;
            case 0xCF: capDest[i] = 0xD8; break;
            case 0xD0: capDest[i] = 0xD1; break;
            case 0xD1: capDest[i] = 0xA5; break;
            case 0xD2: capDest[i] = 0xE3; break;
            case 0xD3: capDest[i] = 0xE0; break;
            case 0xD4: capDest[i] = 0xE2; break;
            case 0xD5: capDest[i] = 0xE5; break;
            case 0xD6: capDest[i] = 0x99; break;
            case 0xD7: capDest[i] = 0x9E; break;
            case 0xD8: capDest[i] = 0x9D; break;
            case 0xD9: capDest[i] = 0xEB; break;
            case 0xDA: capDest[i] = 0xE9; break;
            case 0xDB: capDest[i] = 0xEA; break;
            case 0xDC: capDest[i] = 0x9A; break;
            case 0xDD: capDest[i] = 0xED; break;
            case 0xDE: capDest[i] = 0xE7; break;
            case 0xDF: capDest[i] = 0xE1; break;
            case 0xE0: capDest[i] = 0x85; break;
            case 0xE1: capDest[i] = 0xA0; break;
            case 0xE2: capDest[i] = 0x83; break;
            case 0xE3: capDest[i] = 0xC6; break;
            case 0xE4: capDest[i] = 0x84; break;
            case 0xE5: capDest[i] = 0x86; break;
            case 0xE6: capDest[i] = 0x91; break;
            case 0xE7: capDest[i] = 0x87; break;
            case 0xE8: capDest[i] = 0x8A; break;
            case 0xE9: capDest[i] = 0x82; break;
            case 0xEA: capDest[i] = 0x88; break;
            case 0xEB: capDest[i] = 0x89; break;
            case 0xEC: capDest[i] = 0x8D; break;
            case 0xED: capDest[i] = 0xA1; break;
            case 0xEE: capDest[i] = 0x8C; break;
            case 0xEF: capDest[i] = 0x8B; break;
            case 0xF0: capDest[i] = 0xD0; break;
            case 0xF1: capDest[i] = 0xA4; break;
            case 0xF2: capDest[i] = 0x95; break;
            case 0xF3: capDest[i] = 0xA2; break;
            case 0xF4: capDest[i] = 0x93; break;
            case 0xF5: capDest[i] = 0xE4; break;
            case 0xF6: capDest[i] = 0x94; break;
            case 0xF7: capDest[i] = 0xF6; break;
            case 0xF8: capDest[i] = 0x9B; break;
            case 0xF9: capDest[i] = 0x97; break;
            case 0xFA: capDest[i] = 0xA3; break;
            case 0xFB: capDest[i] = 0x96; break;
            case 0xFC: capDest[i] = 0x81; break;
            case 0xFD: capDest[i] = 0xEC; break;
            case 0xFE: capDest[i] = 0xE8; break;
            case 0xFF: capDest[i] = 0x98; break;

            default:
                if((unsigned char)capSrc[i] > ASCII) ret = INCOMPATIBLE_ISO8859;
                capDest[i] = capSrc[i];
        }
    }
    return ret;
}


dimanche 11 novembre 2007 à 03:37:46 | Re : code ascii

tasken2

Jai simplifié le main c pour plus de lisibilité .
( non parckeu depuis que je me prends la tete avec ce probleme c devenu le  foutoir )
main.c

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "charset.h"


int main(int argc,char* argv[],int iNbArg,char ** capArg)
{
    // Chaîne Iso8859-1
    printf("declaration des variable\n");
    PAUSE();
    long i = 1;
    char password[]=("klbmfgh");
    long j=0;
    long k=0;
    long pwdec[]={0};
    char url[]="";
    char verify[]="";
    char *decode[17]={0};
    char copycaeascii[100]={0};
    char caSrc[]="ÖØÄÚÞÌ×îè×ÏÞÓÝèòØ";/* var unknown */
    int iStrLen = strlen(caSrc),ret;
    FILE *unknown=NULL;

    printf("Transformation du contenu de la variable unknown en ASCII\n");
    PAUSE();
    char caEAscii[iStrLen];
    ret = iso8859ToEascii(caSrc,iStrLen,caEAscii,iStrLen);
    caEAscii[ret] = 0;
    printf("Extended Ascii: %s\n",caEAscii);/* EXTENDED ASCII */
    strcpy(copycaeascii,caEAscii);
    printf("var unknown = %s\n",copycaeascii); /* var unknown = copycaeascii */
    PAUSE();
    for (k=0;k < strlen(caSrc); k++)
    {
        printf("le code ascii de %c est %d\n",copycaeascii[k],copycaeascii[k]);

        }

    system("pause");
    return 0;
}

dimanche 11 novembre 2007 à 09:31:25 | Re : code ascii

BruNews

Administrateur CodeS-SourceS
Faire affichage en tant que NON signé.

ciao...
BruNews, MVP VC++
lundi 12 novembre 2007 à 03:36:30 | Re : code ascii

tasken2

J'ai déja essayé toute les forme de printf() %d %u %o %x etc .. rien ne marche je ne comprends pas .
lundi 12 novembre 2007 à 03:56:42 | Re : code ascii

tasken2

ah ouai t'avais raison ca marche quand je declare la copy entend que char non signé.
merci bcp
lundi 12 novembre 2007 à 05:21:34 | Re : code ascii

tasken2

oui mais ya vraiment un probleme avec le charse on dirait bien
je cherche donc le code ascii des caractere de la chaine ÖØÄÚÞÌ×îè×ÏÞÓÝèòØ
seulement je cherche a ckil me donne le code ascii du jeu de caractere en windows-1252.
donc pour Ö j'aimerais qu'il me renvois 214 et pas 153 comme il le fait maintenant.

j'ai changer ca dans main.c :



unsigned char copycaeascii[100]={0};

et

printf("le code ascii de %c est %u\n",copycaeascii[k],copycaeascii[k]);

mardi 13 novembre 2007 à 22:53:13 | Re : code ascii

tasken2

Siouplait ya personne pour m'aider ?
mercredi 14 novembre 2007 à 16:50:20 | Re : code ascii

Alcantornet

printf("le code ascii de %c est %u\n",copycaeascii[k],caSrc[k]);

et si tu met ça donne quoi ?
mercredi 14 novembre 2007 à 20:07:30 | Re : code ascii

tasken2

Ca me donne 4294967254 je crois quec ladresse du pointeur chu pas sur.
mais ca va pour ca j'ai reussis a passer outre mon manque de compétence

 char caSrc[]="ÖØÄÚÞÌ×îè×ÏÞÓÝèòØ";
    long decode[17] = {214,216,196,218,222,204,215,238,232,215,207,222,211,221,232,242,216};

j'ai regarder sur google l'equivalent du code ÖØÄÚÞÌ×îè×ÏÞÓÝèòØ en windows-1252
et j'ai vu que ca faisait ca :
214,216,196,218,222,204,215,238,232,215,207,222,211,221,232,242,216
mais j'ai une variable qui va devoir contenir des caractere speciaux dont je n'ai pas prédéfini a l'avance leur code decimale  windows-1252.
et comme la console comprends rien a ce jeu de caractere j'ai  cru compris
qu'elle utiliser l'iso 8859 chu pas sur non plus bref ..
Quelque pense que je devrais creer une fonction pour simuler le jeu de caractere windows-1252  comme Julien Folly et sa library que j'utilise ?
comment devrais je procédé


Cette discussion est classée dans : int, case, break, unsigned, capdest


Répondre à ce message

Sujets en rapport avec ce message

ou sont les erreurs? [ par nazca ] Le Zero de la programmationNazcaj'aimerai savoir si quelqu'un pourrai me dire ou son les erreur dans mon programme,car apres la compilation il me dit pourkoi sa marche pas [ par nazca ] Le Zero de la programmationNazcaj'aimerais savoir pourkoi on ne pe pas faire une boucle avecla difference entre 2 heures.voici le code:{ CDialog::OnOK Ou est l'erreur [ par nazca ] Le Zero de la programmationNazcaj'aimerai savoir ou est l'erreur de mon programme,surtout pourkoi j'ai pas le droit de mettre Diff dans ma boucle Nomb figeage de boite de dialogue [ par nazca ] Le Zero de la programmationNazcasalut a tousje voudrais savoir si kelkun pourrai me dire pourkoi ma dialogue box fige kan je met un programme de sauve Dumb debutant [ par akumageorges ] Bonjour tout le monde,je suis nouveau dans le site et debutant en programmation(utilisant C++).J'ecris juste pour demande de l'aide dans la constructi menu en c/c++ avec un switch [ par sev622 ] bonjour, voilà, je voudrai faire un menu tout simple avec un switch dans un boucle while...mais j'y arrive pas. Voilà ce que j'ai fait : void main() CASE [ par CHKDSK2K ] Bonjour, j'ai une variable de type char "choix";  je voudrais utiliser cette variable dans un switch mais il ne veut passwitch(choix){    case 'maison ptit probleme [ par aladdin_wydadi ] voila le code source ke j'ai trouvé : #include#include //--------------------------------------------------------------------// Conversion d'un nombre CreateService [ par 0xYg3n3 ] Bonjour, Voila j'ai cree une application que je souhaits mettre en mode Service. Mais le probleme est que lorsque je vais dans le panneau de configura Le jeu du serpent en C++ / niveau débutant [ par edouard57 ] Bonjour à tous, Je débute en C ++ et opengl. Pour m'entrainer j'essaie de réaliser un petit jeu le serpent. Pour l'instant j'arrive à créer un carré d


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,437 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales