c ++ version print ascii code table --wcout

/*
 * C++ Program to Print ASCII table (0 - 127)
 */
 
#include<iostream>
#include<iomanip>
using namespace std;
 
wchar_t const* character[] = {L"NULL(空)", L"SOH(标题开始)", L"STX(正文开始)", L"ETX (正文结束)", L"EOT (传送结束)", 
                              L"ENQ (询问)", L"ACK (确认)", 
                            L"\\a",L"\\b",L"\\t",L"\\n",L"\\v",L"\\f",L"\\r",L"SO(移出)",L"SI(移入)", 
                              L"DLE(退出数据链)",
                            L"DC1 (设备控制1)", L"DC2(设备控制2)", L"DC3(设备控制3)", L"DC4(设备控制4)",
                              L"NAK (反确认)", L"SYN (同步空闲)", L"ETB (传输块结束)", L"CAN (取消)",
                            L"EM (媒介结束)", L"SUB (替换)", L"ESC (退出)", L"FS (文件分隔符)",
                              L"GS (组分隔符)", L"RS (记录分隔符)", L"US (单元分隔符)", L"(空格)"};
 
int main()
{
    locale::global(locale(""));
    wcout.imbue(locale(""));
    wchar_t c;
    int row;
    wcout << L" ASCII Table" << endl << L"=============" << endl;
    for(int i = 0; i < 32; i++)
    {
        row = i;
        while (row <= 127) {
            if (row <= 32){
                int len2=wcslen(character[row]);
                
                int width=15-(wcswidth(character[row],len2)-len2);
                wcout << setfill(L'0') << setw(2) << setbase(16)
                     << row << L" = " << setw(width) << setfill(L' ')
                     << character[row] << L" | ";
            }
            else if (row > 32 && row < 127)
            {
                c = (wchar_t)row;
                wcout << setfill(L'0') << setw(2) << setbase(16)
                     << row << L" = " << setw(15) << setfill(L' ')
                     << c << L" | ";
            }
            else
                wcout << setfill(L'0') << setw(2) << setbase(16)
                     << row << L" = " << setw(15) << setfill(L' ')
                     << L"DEL" << L" | ";
            row = row + 32;
        }
        wcout << endl;
    }
} 
The Table ASCII 
============= 
00 = NULL (empty) | 20 = (space) | @ 40 = | = `60 | 
01 = SOH (start of heading) | 21 = |! 41 = A | 61 is = A | 
02 = STX (start of text) | 22 is = "| 42 is = B | 62 is = B | 
03 = the ETX (end of text) | 23 is = # | 43 is = C | 63 is = C | 
04 = the EOT ( transfer end) | 24 = $ | 44 is = D | 64 = D | 
05 = ENQ (inquiry) | 25 =% | 45 = E | 65 = E |  
06 = the ACK (acknowledgment) | 26 = & | 46 = F | 66 = f |
07 = \ A | 27 = '| 47 = G | 67 = g |
08 = \ B | 28 = (| 48 = H | 68 = H | 
09 = \ T | 29 =) | 49 = the I | 69 = I | 
0A = \ n-|. 2A = * |. 4A = J |. 6A = J | 
0B = \ V | 2B = + | 4B = K | 6B = K | 
0c = \ F | 2C =, | 4C = L | 6C = L | 
0D = \ R & lt | 2D = - | 4D = M | 6D = m | 
0e =        SO(移出) | 2e =               . | 4e =               N | 6e =               n | 
0F = the SI (moved) |. 2F = / | 4F = O | O 6F = | 
10 = the DLE (data link exit) | 30 = 0 | 50 = P | 70 = p |
11 = DC1 (Device Control. 1) | 31 is =. 1 | 51 is = Q | 71 is = Q | 
12 is = DC2 (Device Control 2) | 32 = 2 | 52 is = R & lt | 72 = R & lt | 
13 is = DC3 (Device Control 3) | 33 is =. 3 | 53 is = S | 73 is = S | 
14 = and DC4 (device control. 4) | 34 is =. 4 | 54 is = T | 74 = T | 
15 = NAK (trans confirmation) | 35 = 5 | 55 = U | 75 = U | 
16 = the SYN (synchronize idle) | 36 =. 6 | 56 is = V | 76 = V | 
. 19 = the EM (end of media) | 39 = 9 | 59 = Y | 79 = y | 
. 17 = ETB (end of transmission block ) | 37 = 7 | 57 = W | 77 = w |
18 = CAN (cancellation) | 38 is =. 8 | 58 = X-| 78 = X |
1a = SUB (replacement) |. 3A =: |. 5A = the Z |. 7A = Z | 
. IB = the ESC (exit) | 3B =; | 5B = [| 7B = {| 
1C = the FS (file separator) | 3c = < | 5C = \ | 7C = | | 
1D = GS (group separator) | 3D = = | 5D =] | 7D =} | 
1E = the RS (record separator) | 3e => | 5e = ^ | 7e = ~ | 
1F = US (cell separator) | 3f = |? 5f = _ | 7f = DEL |
Published 14 original articles · won praise 3 · Views 1261

Guess you like

Origin blog.csdn.net/sinat_18811413/article/details/104108287