Unicode rendering (Updated)
I posted my question couple days ago while i was still working on my code. I will restate my question so it would be clear for everyone.
Goal: print All of the Unicodes available using a loop.
http://i.stack.imgur.com/rZWP8.jpg
Question: why I can only print them, as symbols, if they were hardcoded in a string rather then a variable.
Output:
U000000
U000001
U000002
...
U000017
U000018
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
|
#include <iostream>
#include <cmath>
using namespace std;
const int HexBase=16;
const int HexMax=15;
const int UniCharMaxPrint=1000;
const int ASCCIAlphaCapBase=48;
int main() {
int DecNum = 0;
int sizeHex= 3;
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;}
//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.