C 在 Windows 裡顯示 DOS 字元

2021-06-14 18:19:09 字數 1332 閱讀 9534

最近正好需要在 windows 裡顯示 dos 字元,特別是 ascii 碼 31 及以下 128 及以上的特殊字元。摸索了一下,找到了乙個還算可以的解決方案。

1. 採用 cp 437 轉換 ascii 碼 128 及以上的字元;

2. ascii 小於 32 的字元可以被解釋為「控制字元」或「影象字元」;windows 的**轉換選擇前一種解釋(例如,cr-lf 作為換行符);

3. 可以自己繼承 encoding 類,實現影象字元的轉換。

dos 下面的特殊字元包括三個部分:chr(0) - chr(31), chr(127), chr(128-255)。

system.text.encoding 類有幾個屬性,可以返回常用的編碼;但是 ascii 編碼只允許 7 位。

下面為了方便,先帖上**,以後再補上文字。

using system;

using system.text;

namespace quickhelp

public static bool containscontrolcharacter(string s)

return false;

}public static void substitutecontrolcharacters(char chars)

public static void substitutecontrolcharacters(char chars, int index, int count)

}public static string substitutecontrolcharacters(string s)

public override int getbytecount(char chars, int index, int count)

public override int getbytes(char chars, int charindex, int charcount, byte bytes, int byteindex)

public override int getcharcount(byte bytes, int index, int count)

public override int getchars(byte bytes, int byteindex, int bytecount, char chars, int charindex)

public override int getmaxbytecount(int charcount)

public override int getmaxcharcount(int bytecount)

}}

code page 437 (wikipedia)

Oracle 在Dos裡 匯入匯出

開始,執行,輸入cmd 資料匯出 1 將資料庫test完全匯出,使用者名稱system 密碼manager 匯出到d daochu.dmp中 exp system manager test file d daochu.dmp full y full y表示完全匯出 2 將資料庫中system使用者和...

python 在windows 中文顯示

今天看到mechanize,在網上找例子實驗,發現只要 裡出現中文,就會報錯 python的預設編碼檔案是用的ascii碼 使用notepad 1 檔案編碼為 以utf 8無bom格式編碼 如果python檔案中使用了中文等非英語字元,就會報錯了 解決的方法 在python原始檔的第一行加上 cod...

python 在windows 中文顯示

今天看到mechanize,在網上找例子實驗,發現只要 裡出現中文,就會報錯 python的預設編碼檔案是用的ascii碼 使用notepad 1 檔案編碼為 以utf 8無bom格式編碼 如果python檔案中使用了中文等非英語字元,就會報錯了 解決的方法 在python原始檔的第一行加上 cod...