C 解碼編碼大檔案

2022-01-11 21:53:25 字數 807 閱讀 5982

因為專案中有個需求把檔案轉成base64,一開始做的思路,是直接把檔案讀到記憶體中,然後在記憶體裡轉成base64 。 但是因為這個方法是公共方法,考慮到別人也可能用到,如果別人轉的是幾個g的大檔案,那麼直接載入到記憶體中,肯定是不行的,會出現記憶體溢位。通過網上查詢資料,總結整理成下面的方法。

下面這個方法,我測試的時候,檔案大小32g,轉成base64,需要20分鐘。

// a code block
/// /// encode  file content base64

///

/// input file path,the file is unencoded

/// encoded output file path

public static void encodebase64file(string filein, string fileout)

}catch (exception ex)

}/// /// decode file content base64

///

/// input file path,the file is unencoded

/// encoded output file path

public static void decodebase64file(string filein, string fileout)

}catch (exception ex)

}

參考鏈結1: link.

參考鏈結2: link.

參考鏈結3: link.

python 檔案編碼 解碼

ascii ascii碼是西歐編碼的方式,採取7位編碼,所以是2 7 128,共可以表示128個字元,包括34個字元,如換行lf,回車cr等 其餘94位為英文本母和標點符號及運算符號等。gb2321 gb2312 是對 ascii 的中文擴充套件。相容ascii。編碼規定 編碼小於127的字元與as...

超大檔案編碼轉換

最近導資料,從gbk轉到utf8,檔案太大了120多m,普通編輯器無法開啟 網上有人用vim轉換,成功率也很高,iconv有時候不能轉換 如開啟windows中以ansi儲存的檔案 vim file.txt c e enc gb18030 在vim中直接進行轉換檔案編碼,比如將乙個檔案轉換成utf ...

JS與C 編碼解碼

escape不編碼字元有69個 0 9,a z,a z encodeuri不編碼字元有82個 0 9,a z,a z encodeuricomponent不編碼字元有71個 0 9,a z,a z 1.js escape js使用資料時可以使用escape 例如 蒐藏中history紀錄。0 255...