Universal Char rendering

hello Cpeps!!

I was watching a Lynda's Tutorial and there was some C mixed with C++.

http://s13.postimg.org/oudnbcv1z/1111.jpg

In this picture the guy had a string with Hex in it and the compiler rendered it as Universal Char any how i decided to run a code that can print all of these universal characters.
I did a dec to hex program then i attached this a string starts with U.

the question is ::: how can i make the program reads it like the guy in lynda did ??



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <cmath>
using namespace std;

const int HexBase=16;
const int HexMax=15;
const int UniCharMaxPrint=100;
const int ASCCIAlphaCapBase=48;


int main() {

    int DecNum = 0;
    int sizeHex= 5;
    
    for (int j=0; j < UniCharMaxPrint; j++)//prints 100 unviersal Chars
    {
        int DecNumCopy = DecNum;
        int resultDiv =0;
        string HexChar=" ";
        string HexNum ="X";
        string UniNum ="U";
        string BackSlash = "\\";
        string full="HI ";
        for (int i = sizeHex; i >=0; i--)
        {
    
            //Dec calcultion
            resultDiv = (DecNumCopy/(int)(pow(HexBase,i)));
            DecNumCopy = DecNumCopy - ((int)(pow(HexBase,i)) * resultDiv);
            if ((i==0) && (resultDiv>HexMax)){cout <<"Error # is Too large"<<endl;}//Check if the number entered is big or not
            
            //Get the equivalente Hex charcter
            if ((resultDiv >= 0)&&(resultDiv <= 9))
            { HexChar = ASCCIAlphaCapBase + resultDiv;}
            else if ((resultDiv >= 10)&&(resultDiv <= 15))
            {   switch (resultDiv)
                {   case 10 : {HexChar='A'; break;};
                    case 11 : {HexChar='B'; break;};
                    case 12 : {HexChar='C'; break;};
                    case 13 : {HexChar='D'; break;};
                    case 14 : {HexChar='E'; break;};
                    case 15 : {HexChar='F'; break;};
                }
            }
            else {HexChar='*';};
            
            
            //if(i==sizeHex){full.append(UniNum);};
            
            
            //Add to the result string
            HexNum.append(HexChar);
            UniNum.append(HexChar);
            full = BackSlash+UniNum;
        }//endfor
        DecNum++;
        cout<< full << endl;
    }
    return 0;
}
Last edited on
Topic archived. No new replies allowed.