จริงๆ ฺBlog อันนี้เป็นสาเหตุของ Blog นี้ครับ [PowerShell] Convert Unicode Text or SQL File To ASCII โดยสาเหตุของ Error Message นี้เกิดจากตัว line termination (ตัวบอกการขึ้นบรรทัดใหม่) ไม่ได้ใช้ตามมาตรฐาน ANSI ซึ่งจะใช้ (Carriage Return, ตัวย่อ CR, ASCII Code =13)

เมื่อเรานำไฟล์จาก Windows ไปใช้งานบน Unix หรือ Linux นะครับ โดยการแก้ไขนั้นง่ายนิดเดียวครับ
- แก้ที่ทาง Windows โดยเวลา save ไฟล์ ให้กำหนด Encoding เป็น ANSI ครับ
- แก้ที่ทาง Linux, unix มีหลายหลากวิธีครับ
- ใช้คำสัง dos2unix ตัวอย่าง dos2unix $filename
- ใช้คำสั่ง tr -d '\015' < $filename > $filename.fixed
- ใช้ Editor ในตำนานอย่าง VI ตามวิธีนี้ แล้ว Save ไฟล์ครับ
- กำหนด Mode ในก่าร transfer the file โดยใช้ ASCII mode
Reference
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.