From owner-freebsd-questions@FreeBSD.ORG Mon May 23 15:50:50 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38076106564A for ; Mon, 23 May 2011 15:50:50 +0000 (UTC) (envelope-from modulok@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id EA2F78FC17 for ; Mon, 23 May 2011 15:50:49 +0000 (UTC) Received: by gwb15 with SMTP id 15so2738162gwb.13 for ; Mon, 23 May 2011 08:50:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=SKGKmarJxGV/Nc/PbpLjBuJOJJzJffj/I1ys2M4bY0E=; b=AV+h2s8Ngs7F+e8ea6Su/X0zKlykEALWvTlwhvQeqMp3e2tKCKW+ettt/iAzNludz1 kAigBv1aXisopnB4WtcvWX9cY23490gVZiJ54k0dHIQqt4R22x2kBACecD9l+vVfIfWI 1/C9246pccb6T8p19qhfRF//eG1REDeYtUXU8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=D91HKZ9PBjx5Y78CnxVQhRDKurtjXt0VlXXMcyFvmRaJFinLLbZishaO/Ic4gX2kbd jdbotUY42dMMRCkHcYLQl+oMgMsMUteoQg0POH6AUn7/WdG5sw/ajj/M7W5Fl+AGIiBf voRtDi0lMiRpWcB08YoWy+k+XNv6sQi6v33O8= MIME-Version: 1.0 Received: by 10.101.179.5 with SMTP id g5mr4403843anp.117.1306165849182; Mon, 23 May 2011 08:50:49 -0700 (PDT) Received: by 10.100.207.9 with HTTP; Mon, 23 May 2011 08:50:48 -0700 (PDT) In-Reply-To: <990E8670-2137-4F80-8D9D-BCEB05C6ECAA@esiee.fr> References: <990E8670-2137-4F80-8D9D-BCEB05C6ECAA@esiee.fr> Date: Mon, 23 May 2011 09:50:48 -0600 Message-ID: From: Modulok To: Frank Bonnet Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: Filename containing French characters ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2011 15:50:50 -0000 Short answer, use a glob pattern. Assume I have a file named '=E0 fichier.t= xt': ls -l -rw-r--r-- 1 Modulok Modulok 12 May 23 09:01 ?? fichier.txt mv ?\ fichier.txt aFile.txt Long answer, for those who want to follow along and fix their terminal to display UTF-8, keep reading... Step 1: Make a funky file to play along with this min-tutorial: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Create a text file with an editor that supports non-ASCII characters. I created a file named 'filename' which containing this (no newline!): =E0 fichier.txt Step 2: Create the actual file with content =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D I used echo and cat like so in the tcsh shell: echo "hello world" > "`cat filename`" Step 3: Show the file in ls =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D As you can see below, the first character of the filename is displayed as t= wo question marks. This is the terminal's way of showing filenames that it can= not display correctly. There are two question marks, because this is a two-byte character. This does *not* mean the filename starts with a literal question mark: -rw-r--r-- 1 Modulok Modulok 12 May 23 09:01 ?? fichier.txt Step 4: (optional) Fix the terminal =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D At this point, let's just fix the terminal so that UTF-8 characters are displayed correctly. We want to see the French accented '=E0', and not a bu= nch of question marks. To do this, you edit '/etc/login.conf' as root. Add two lin= es at the bottom of the 'default' section. My default section now looks like t= his: default:\ :passwd_format=3Dmd5:\ :copyright=3D/etc/COPYRIGHT:\ ...and so on... :charset=3Den_US.UTF-8:\ :lang=3Den_US.UTF-8: If you're a French operation yours should probably look like this instead: default:\ :passwd_format=3Dmd5:\ :copyright=3D/etc/COPYRIGHT:\ ...and so on... :charset=3Dfr_FR.UTF-8:\ :lang=3Dfr_FR.UTF-8: I'm not certain on these for all countries, but the above examples work. We then need to rebuild the actual login database. Execute the following comma= nd as root: cap_mkdb /etc/login.conf This generates /etc/login.conf.db from /etc/login.conf. Now log out and the= n back in! Step 5: Back to the funky file =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D You should now see the actual accent characters correctly in the terminal. (Assuming your terminal supports this): -rw-r--r-- 1 Modulok Modulok 12 May 23 09:01 =E0 fichier.txt In some ternimals, we cannot type these characters. So you can access the filename through a shell glob pattern. In most shells, the glob pattern '?' matches any single character. The forward slash escapes the space in the filename. mv ?\ fichier.txt aFile.txt Hope this helps (and doesn't get too mangled.) -Modulok-