# Indexing a non-utf-8 encoded file (ANSI) with special characters

I'm using xindy to make an index for my book, which is in Icelandic. It sorts the words mostly correctly, but it doesn't sort accented characters (i.e. á é í ó ú ý) after the corresponding non-accented characters (a e i o u y), unless the words are otherwise identical. See my previous question. There is a solution (see the answer), but it only works for utf-8-encoded files, and my document is in ANSI. I cannot change the encoding to utf-8 without creating some errors because there are labels with special characters.

What I'm hoping for is a solution analogous to the previous question that works for non-utf-8 files. Alternatively, if there was some easy way to change the alphabetical order xindy uses, that would be great. I can't seem to find any documentation for xindy that I can understand.

Here's my MWE:

% filename alphabet.tex
\documentclass[a4paper,11pt]{book}
\usepackage[icelandic]{babel}
\usepackage[T1]{fontenc}
\usepackage{makeidx}
\makeindex

\title{My book}
\author{Me}
\begin{document}
\chapter{Stafrófið}

Ananas\index{ananas}, ás\index{ás},
banani\index{banani}, dagblað\index{dagblað}, epli\index{epli}, ég\index{ég}, flugvél\index{flugvél}, gíraffi\index{gíraffi}, hús\index{hús}, indíáni\index{indíáni}, ís\index{ís}, jörðin\index{jörðin}, kisa\index{kisa}, lykill\index{lykill}, mús\index{mús},
nef\index{nef}, ormur\index{ormur}, óbó\index{óbó}, píanó\index{píanó}, rós\index{rós}, skæri\index{skæri}, tré\index{tré}, ugla\index{ugla}, úr\index{úr}, varir\index{varir}, yddari\index{yddari}, ýta\index{ýta}, þvottavél\index{þvottavél}, æð\index{æð}, ör\index{ör}, auga\index{auga}, eyra\index{eyra}.

\printindex
\end{document}


I compile it using

pdflatex alphabet.tex
texindy -L icelandic alphabet.idx
pdflatex alphabet.tex

• You don't say how you tried changing the encoding. Nor, for that matter, do you mention the encoding you are using or tell us how you are informing TeX of that encoding. Are these characters in T1? If not, how are you producing them? – cfr Jul 12 '15 at 0:20
• @cfr I'm afraid I don't know the encoding, all I know is that the document compiles and all the characters display correctly. Is there any way to check? I converted to utf-8 using the editor vim. – Pétur Jul 12 '15 at 0:22
• The thing is, to even test your MWE, I have to do something to specify the encoding. Otherwise it compiles, but the special characters it includes are... well, I suppose 'special' would be one description but 'screwed up' would be another. So I use \usepackage[utf8]{inputenc} and it all comes out nicely. (Since my test file is saved in this encoding.) But now I'm not reproducing your situation at all. How to find the encoding? On Linux/OS X, I would use file <filename>.tex and it will tell me the file type, including encoding. If I 'save as...' my editor will show me the encoding, too. – cfr Jul 12 '15 at 0:29
• As you use non-ASCII chars you certainly must load inputenc. Try \usepackage[ansinew]{inputenc} . – Ulrike Fischer Jul 12 '15 at 9:25
• Without inputenc non-ascii chars gives the correct output only for a subset of the possible input. Try "Grüße" to see the problem. If you get errors when using inputenc then your document is faulty -- labels shouldn't use non-ascii chars. You should better correct your document instead of wasting time (or hoping that someone else spend the time) to find some workarounds. – Ulrike Fischer Jul 12 '15 at 10:43