#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
void revise(unsigned char* str) {
int len = strlen((char*)str);
unsigned char tmp[1024];
unsigned char* p1 = str;
unsigned char* p2 = tmp;
p2 = tmp + len;
*p2 = 0;
p2--;
while (*p1!='\0') {
if (*p1 < 128) {
*p2= *p1;
p2--;
p1++;
}
else {
*(p2 - 1) = *p1++;
*p2 = *p1++;
p2 -= 2;
}
}
for (int i = 0; i < len; i++) {
str[i] = tmp[i];
}
}
int main(void) {
unsigned char str[] = { "我爱你" };
revise(str);
cout << str << endl;
system("pause");
return 0;
}
效果演示: