[CGI]如何將中文字串存入檔案時,以UTF8格式儲存

因為網頁的介面是以BIG5為主的頁面,雖然如果用UTF8也可以

但是數量太多了,要改實在很麻煩,所以有沒有辦法可以將表格傳來的值,以UTF8的方式存在檔案中,當然檔案的格式也是UTF8,我英文是已經可以存

但是如果是存進中文的就會有問題!

請各位大大指教!

1 Answer

Rating
  • 2 decades ago
    Favorite Answer

    CAVEAT: The following operations look the same but are not quite so;

    from_to($data, "big5", "utf8"); #1

    $data = decode("big5", $data); #2Both #1 and #2 make $data consist of a completely valid UTF-8 string but only #2 turns utf8 flag on. #1 is equivalent to

    $data = encode("utf8", decode("big5", $data));

    Source(s): 手邊自己留的資料
Still have questions? Get your answers by asking now.