nbe.cpp

来自「非常好用的五子棋游戏源码」· C++ 代码 · 共 50 行

CPP
50
字号
// Created:10-24-98
// By Jeff Connelly

// NBEncoding (nibble-byte encoding)

// Converts binary to plain text, like UUE and HEX

// A byte is splitted into two bytes, thus:
//     a and b are nibbles, f is a fixed nibble that is always the same
//     ab -> fafb
// Example help:
// Data: 1010    0101
//       high    low
//
// Encoded: 0100 1010 0100 0101
//         FIXED high FIXED low
// 
// The 'fixed' bytes are always the same.

#include "stdafx.h"
#define EXPORTING
#include "comprlib.h"

void EXPORT nb_encode()
{
    register char c;        // Character
    register char h, l;     // High and low nibbles
    const char fixed = 4;   // Fixed nibble = 0100

    while (!end_of_data())
    {
        c = read_byte();

        // Isolate the nibbles
        h = c & 0xF0;
        l = c & 0x0F;

        // Apply 'fixed' constent
        h |= fixed;
        l |= fixed;

        write_byte(h);
        write_byte(l);
    }
}

void EXPORT nb_decode()
{
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?