如何在算法上使用字符编码算法? [英] How to use character encoding algorithm on the algorithm?

查看:71
本文介绍了如何在算法上使用字符编码算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

下面的C代码将字符转换为7位编码:

Hello,
The C code below converts characters to 7bit encodings:

int n = 0;
unsigned char a = 0;
unsigned char b = 0;
while (read_byte(&byte))
{
    a |= (b >> (n + 2)) & (077 >> n);
    store_7bit(a);
    a = 0;
    a |= (b << (5 - n)) & ((077 << (5 - n)) & 077);
    if (n == 5)
    {
        store_7bit(a);
        a = 0;
    }
    n = (n + 2) % 7;
}





我的任务是使用该算法在C编程中动态地将字符转换为7位编码,但是不知道。

这是怎么做的?



I have been tasked to use the algorithm to convert characters to 7bit encodings on the fly in C programming, but have no idea.
How is this done?

推荐答案

只需更换

Just replace
while (read_byte(&byte)) {

使用循环遍历您的数据。



但在你做之前,我会测试那段代码,因为它目前对我来说看起来不太合适。它实际上并不使用您在...中读取的数据...

With a loop that runs through your data.

But before you do, I'd test that code, as it doesn't look like it works to me at present. It doesn't actually use the data you read in...


这篇关于如何在算法上使用字符编码算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆