discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode and GNUstep (more info)


From: Pascal Bourguignon
Subject: Re: Unicode and GNUstep (more info)
Date: Sat, 11 May 2002 16:17:19 +0200 (CEST)

> > So, just edit a file test.txt containing: @"öôóò"
> > and  use the command: od -tx1 ~/test.txt
> > see if you get this:
> >
> >     0000000 40 22 f6 f4 f3 f2 22 0a           This is ISO-8859-1
> >     0000010
> >
> > or this:
> >
> >     0000000 40 22 9a 99 97 98 22 0a          This is Macintosh encoding.
> 
> I am accessing the Sun machine via telnet from my MacOSX box. I put the 
> above string in a text file and saved it with Western (MacOS Roman) 
> encoding on the sun server (NFS). I then logged into the sun and did
> 
> bash-2.03# od -tx1 Test.txt
> 0000000 40 22 9a 99 97 98 22
> 0000007
> bash-2.03#
> 
> so this is MacOS encoding.

Unsurprizingly.
 
> I then opened the file on the sun box in the telnet session using pico 
> and got
> 
> @"????"

Unsurprizingly again.   Sun works probably in ISO-8859-1,  so it can't
display  half the  accenter characters  of Macintosh  that lie  in the
range  0x80-0x9f  (considered as  control  codes  in ISO-88590-1  like
0x00-0x1f).
 
> cat delivers the same result. I then changed the encoding in the 
> preferences of Terminal.app to MacOS Roman and retried. cat and pico did 
> now deliver the expected result. So far so good.

A good move.  If you're going to work only with  the terminal and from
Macintosh, that is.

 
> I would like to edit my files on MacOSX with MacOS Roamn coding (cannot 
> change this since ProjectBuilder does not allow to use another 
> encoding). How can I cause GNUstep on Solaris to use MacOS encoding 
> (value for GNUSTEP_STRING_ENCODING)?



But if, like  it seems, you have Macintosh  encoded files and sources,
then you will need to use:

export GNUSTEP_STRING_ENCODING=NSMacOSRomanStringEncoding
./FBTest.app/FBTest


(and better put this line:
    export GNUSTEP_STRING_ENCODING=NSMacOSRomanStringEncoding
in your .profile, .bashrc, .kshrc or whatever, or write it as:
    setenv GNUSTEP_STRING_ENCODING NSMacOSRomanStringEncoding
in our .cshrc if you use csh or tcsh).



Plus, keep  your setting in  Terminal.app to interpret  the characters
sent by the sun as Macintosh encoding.

But you're bound to hit the symetrical problem, when you'll be editing
sun files  containing ISO-8859-1 accents  on the Terminal,  or loading
them from your  GNUstep application.  And how will  you explain to the
sun  users  of  your application  that  they  have  to switch  to  the
Macintosh  encoding, to  use it,  while  all their  sun documents  are
already in ISO-8859-1?

For the same  reason mac users and mac  applications stay in Macintosh
encoding, you should  keep the sun application in  the native encoding
(which I believe is ISO-8859-1 on sun).


So the right  move would be to convert your  sources, for example with
(GNU) iconv.

Anyway, if  you want  to use the  same sources  both in MacOSX  and in
GNUstep, you have to have some  different files, such as the main, the
makefiles, etc.

What I do, is to have these directories:

     ${project}                 The common sources
     ${project}-mx              The sources specific to MacOSX
     ${project}-gs              The sources specific to GNUstep
     ${project}-os              The sources specifit to OPENSTEP

There's  no makefile  in ${project},  I just  put there  a  file named
common-sources.make containing  the definition of  make variable named
COMMON_SOURCES  which   lists  all  the  sources   in  the  ${project}
directory.


There, I'll explain what I have in ${project}-os, because I never done
it for ${project}-mx, but it should be very similar:

In Makefile.preamble, I add this:
------------------------------------------------------------------------
BEFORE_PREBUID += link-sources

COMMON_DIR=../${project}
include $(COMMON_DIR)/common-sources.make
$(COMMON_SOURCES)::link-sources
link-sources:
        -rm -f $(COMMON_SOURCES)
        for src in $(COMMON_SOURCES) ; do ln -s $(COMMON_DIR)/$$src . ; done

cleanall::clean
        -rm -f $(COMMON_SOURCES)
------------------------------------------------------------------------

And similarly in GNUmakefile.postamble:
------------------------------------------------------------------------
before-all::link-sources

COMMON_DIR=../${project}
include $(COMMON_DIR)/common-sources.make
$(COMMON_SOURCES)::link-sources check-libraries
link-sources:
        for src in $(COMMON_SOURCES) ; do ln -sf $(COMMON_DIR)/$$src . ; done

cleanall::clean
        -rm -f $(COMMON_SOURCES)
------------------------------------------------------------------------

(Note that  on OPENSTEP, it's  BSD ln which  does not have  -f option,
while on GNUstep/Linux, I use GNU ln with -f option which let me avoid
the previous rm -f. On GNUstep/Solaris you'll probably have to use the
same as for OPENSTEP and MacOSX).


If you have subprojects, you should replicate the subproject hierarchy
in all  the ${project}*  directories, and add  a similar chunk  to the
*akefile.preample in each subproject.

In ${project}-gs/${subproject}.subproj/GNUmakefile.postamble :
------------------------------------------------------------------------
before-all::link-sources

COMMON_DIR=../../${project}/${subproject}.subproj
include $(COMMON_DIR)/common-sources.make
$(COMMON_SOURCES)::link-sources
link-sources:
        for src in $(COMMON_SOURCES) ; do ln -sf $(COMMON_DIR)/$$src . ; done

cleanall::clean
        -rm -f $(COMMON_SOURCES)
------------------------------------------------------------------------
etc.



So, the application for which I did that was in english, so I did fall
in  this  trap with  respect  to  the  nextstep encoding  of  OPENSTEP
vs. ISO-8859-1  on Linux.  But  it would be  easy to replace  the link
with  an iconv/copy.  Only it  should be  taken care  not to  edit the
copied files.


In the GNUmakefile.postamble for sun, I'd use:
------------------------------------------------------------------------
before-all::copy-and-conv-sources

COMMON_DIR=../${project}
include $(COMMON_DIR)/common-sources.make
$(COMMON_SOURCES)::copy-and-conv-sources
copy-and-conv-sources:
        -rm -f $(COMMON_SOURCES)
        for src in $(COMMON_SOURCES) ; do \
        echo "#line 1 \"$(COMMON_DIR)/$$src\"" > $$src ;\
            iconv -f MACINTOSH -t ISO8859-1 < $(COMMON_DIR)/$$src >> $$src ;\
            chmod a-w $$src ;\
        done

cleanall::clean
        -rm -f $(COMMON_SOURCES)
------------------------------------------------------------------------



-- 
__Pascal_Bourguignon__             (o_ Software patents are endangering
() ASCII ribbon against html email //\ the computer industry all around
/\ and Microsoft attachments.      V_/ the world http://lpf.ai.mit.edu/
1962:DO5K=1.3   2001:my($f)=`fortune`;   http://petition.eurolinux.org/

You're a web designer?   Please read http://www.useit.com/alertbox/ !

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++  UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++
------END GEEK CODE BLOCK------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]