Fonts & Character SetsSaving Japanese to the tex file

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
User1291
Posts: 5
Joined: Sat Jun 22, 2013 10:14 am

Saving Japanese to the tex file

Post by User1291 »

I am trying to add some japanese to an otherwise english document.
Here's my attempt:

Code: Select all

\documentclass[11pt, pdftex, a4page, utf8]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
%...
\usepackage{CJK}
\newcommand{\jap}[1]{\begin{CJK}{UTF8}{min}#1\end{CJK}}
%...
\begin{document}
%...
\jap{よろしくお願いします}
%...
\end{document}
Now, what I get, when I compile that is a row of question marks instead of the japanese characters.
What's more, when I close the editor (using TeXstudio on Win7, btw), the characters in the tex file have also been replaced with question marks:
\jap{??????????}

So ... why is that, and how do I make it work like I intend it to?
Any help with this would be appreciated.
Last edited by cgnieder on Sat Jun 22, 2013 10:54 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Saving Japanese to the tex file

Post by cgnieder »

Hi User1291,

Welcome to the LaTeX community!

This is most likely an encoding problem. You need to make sure that your editor saves the file in the same encoding that you specified as option for inputenc, i.e., unicode encoding for utf8. I am not familiar with TeXstudio so I can't tell you where to look but it should have some menu for this.

Regards
site moderator & package author
User1291
Posts: 5
Joined: Sat Jun 22, 2013 10:14 am

Saving Japanese to the tex file

Post by User1291 »

I can now open and close the file without loosing the characters. (Took me long enough to find the option.) Thank you.

However, I am now getting lots of errors I'm not sure what to do with:
errors-japanese.jpg
errors-japanese.jpg (121.92 KiB) Viewed 5673 times
In case you were wondering, line 64 would be \jap{よろしくお願いします}. :mrgreen:
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Saving Japanese to the tex file

Post by cgnieder »

User1291 wrote:[...] I am now getting a shitload of errors I'm not sure what to do [...]
These are not the errors from the Infominimal working example you posted in your first post and the errors seem unrelated to the question from this thread. I suggest you try to build another Infominimal working example the reproduces the first error message you're getting and post a new question in a new thread.

Regards
site moderator & package author
Post Reply