DEV Community

Kaziu
Kaziu

Posted on • Edited on

5 2

🤨 How to change character code on Mac?

💎 I got sql file from friend who uses Windows

But I could not execute it on my Mac because of character error

Windows Mac
Shift JIS UTF-8

â–¼ Japanese characters are corrupted

INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(1,'2010/07/23 12:19:45','ono1','shinichi1','1-a-1','備考AAAAAA1')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(2,'2010/07/23 12:20:45','ono2','shinichi2','1-a-2','備考AAAAAA2')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(3,'2010/07/23 12:21:45','ono3','shinichi3','1-a-3','備考AAAAAA3')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(4,'2010/07/23 12:22:45','ono4','shinichi4','1-a-4','備考AAAAAA4')
...
Enter fullscreen mode Exit fullscreen mode

💎 How to resolve it?

install nkf

$ brew install nkf

// check file character code
$ nkf -g file.sql
Shift_JIS

// I wanna change to UTF-8
$ nkf -w --overwrite file.sql
Enter fullscreen mode Exit fullscreen mode

then resolved !

INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(1,'2010/07/23 12:19:45','ono1','shinichi1','1-a-1','備考AAAAAA1')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(2,'2010/07/23 12:20:45','ono2','shinichi2','1-a-2','備考AAAAAA2')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(3,'2010/07/23 12:21:45','ono3','shinichi3','1-a-3','備考AAAAAA3')
INSERT INTO Shain(Id,CreateDate,Sei,Mei,Tel,Bikou) VALUES(4,'2010/07/23 12:22:45','ono4','shinichi4','1-a-4','備考AAAAAA4')
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
spo0q profile image
spO0q •

Thanks for sharing I did not know this kanji code converter.

Collapse
 
kaziusan profile image
Kaziu •

You're welcome !

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay