Hello
I cannot find any encoding settings for opening files in Numbers 09.
A simple and obvious solution would be to save CSV file in UTF-8 in FAT32 volume in VirtualBox if possible.
One other method is to copy the CSV file to HFS+ volume and set its extended attributes to specify its text encoding. This method is only changing the metadata of the file and so is less intrusive than to convert the data itself to different text encoding. When text encoding extended attribute is properly set, Numbers 09 (and TextEdit.app set to use "Automatic" encoding option in opening files) will open it in the specified text encoding.
The following AppleScript script might help to set the extended attributes (OSX 10.5 or later only). Recipe is as follows.
A1) Open /Applications/Utilities/AppleScript Editor.app, copy the code of set_latin1_xattr.applescript listed below and save it as application (bundle) in the folder where target CSV files reside.
A2) Double click the saved applet and it will set the com.apple.TextEncoding extended attribute of the *.csv and *.txt files in the same folder where the applet resides to Latin 1 when they are recognised as 'ISO-8859 text' by file(1) command.
-- set_latin1_xattr.applescript
_main()
on _main()
set p2m to (path to me)'s POSIX path
if p2m ends with "/" then set p2m to p2m's text 1 thru -2
set sh to "
# set current directory to parent directory of script (or die)
cd \"${0%/*}\" || exit 1
# add com.apple.TextEnncoding xattr for Latin-1
# for *.csv and *.txt files, of which file info contains 'ISO-8859 text', in current directory
for f in *.{csv,txt}
do
if [[ $(file \"$f\") =~ 'ISO-8859 text' ]]
then
xattr -w com.apple.TextEncoding \"WINDOWS-1252;$((0x0500))\" \"$f\"
fi
done
"
do shell script "/bin/bash -c " & sh's quoted form & " " & p2m's quoted form
end _main
Another method is to convert the text encoding itself as you have already done using TextEdit.app.
The following AppleScript might help to convert text encoding from latin-1 to utf-8 in bulk. Recipe is basically the same as the above.
B1) Open /Applications/Utilities/AppleScript Editor.app, copy the code of convert_latin1_to_utf8.applescript listed below and save it as application (bundle) in the folder where target CSV files reside.
B2) Double click the saved applet and it will convert the text encoding of the *.csv and *.txt files in the same folder where the applet resides to UTF-8 when they are recognised as 'ISO-8859 text' by file(1) command. Also it sets the extended attribute for text encoding accordingly.
-- convert_latin1_to_utf8.applescript
_main()
on _main()
set p2m to (path to me)'s POSIX path
if p2m ends with "/" then set p2m to p2m's text 1 thru -2
set sh to "
# set current directory to parent directory of script (or die)
cd \"${0%/*}\" || exit 1
# make temporary directory
temp=$(mktemp -d /tmp/\"${0##*/}\".XXXXXX) || exit 1
# convert text encoding from ISO-8859-1 to UTF-8
# for *.csv and *.txt files, of which file info contains 'ISO-8859 text', in current directory
for f in *.{csv,txt}
do
if [[ $(file \"$f\") =~ 'ISO-8859 text' ]]
then
iconv -f ISO-8859-1 -t UTF-8 \"$f\" > \"$temp/$f\" \\
&& xattr -w com.apple.TextEncoding \"UTF-8;$((0x08000100))\" \"$temp/$f\" \\
&& mv -f \"$temp/$f\" \"$f\"
fi
done
# clean up temporary directory
rm -rf \"$temp\"
"
do shell script "/bin/bash -c " & sh's quoted form & " " & p2m's quoted form
end _main
Note that the extended attribute is not supported in FAT32 and so the above methods only work in HFS+ formatted volume.
Scripts are briefly tested with Numbers 2.0.5 under OSX 10.5.8 and 10.6.5. Please make sure you have backup CSV files before applying the above scripts.
Good luck,
H