Thread: to_ascii()

to_ascii()

From
Karel Zak
Date:
 to_ascii( text )

    - encode 'text' from database encoding to ASCII

    to_ascii('\256\341k')


 to_ascii( text, int4 )

    - encode 'text' from 'int4' encoding to ASCII

       to_ascii('\256\341k', 8)


 to_ascii( text, name )

    - encode 'text' from 'name' encoding to ASCII

      to_ascii('\256\341k', 'LATIN2')


  Now is supported LATIN1, LATIN2, WIN1250. For other character sets I
haven't good resources. Add new encoding is easy...

 If encoding is not supported returns ERROR.

 Note --- not exists total corect conversion to ASCII, this function try
    convert chars those is _probably_ interpret-able in ASCII for
    others use ' '. But for example for all Czech characters it is
    sufficient ... hmm Chinese / JAP and other complicated langs have
    bad luck here :-(

                        Karel

Attachment

Re: to_ascii()

From
Bruce Momjian
Date:
Applied.

>
>  to_ascii( text )
>
>     - encode 'text' from database encoding to ASCII
>
>     to_ascii('\256\341k')
>
>
>  to_ascii( text, int4 )
>
>     - encode 'text' from 'int4' encoding to ASCII
>
>        to_ascii('\256\341k', 8)
>
>
>  to_ascii( text, name )
>
>     - encode 'text' from 'name' encoding to ASCII
>
>       to_ascii('\256\341k', 'LATIN2')
>
>
>   Now is supported LATIN1, LATIN2, WIN1250. For other character sets I
> haven't good resources. Add new encoding is easy...
>
>  If encoding is not supported returns ERROR.
>
>  Note --- not exists total corect conversion to ASCII, this function try
>     convert chars those is _probably_ interpret-able in ASCII for
>     others use ' '. But for example for all Czech characters it is
>     sufficient ... hmm Chinese / JAP and other complicated langs have
>     bad luck here :-(
>
>                         Karel
Content-Description:

[ application/x-gzip is not supported, skipping... ]


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: to_ascii()

From
Karel Zak
Date:
On Fri, 4 Aug 2000, Bruce Momjian wrote:

> Applied.
>

 Thanks.

                Karel


Re: to_ascii()

From
Bruce Momjian
Date:
I had to back out the patch. It only compiles with multi-byte enabled.

Please submit a new patch.

> Applied.
>
> >
> >  to_ascii( text )
> >
> >     - encode 'text' from database encoding to ASCII
> >
> >     to_ascii('\256\341k')
> >
> >
> >  to_ascii( text, int4 )
> >
> >     - encode 'text' from 'int4' encoding to ASCII
> >
> >        to_ascii('\256\341k', 8)
> >
> >
> >  to_ascii( text, name )
> >
> >     - encode 'text' from 'name' encoding to ASCII
> >
> >       to_ascii('\256\341k', 'LATIN2')
> >
> >
> >   Now is supported LATIN1, LATIN2, WIN1250. For other character sets I
> > haven't good resources. Add new encoding is easy...
> >
> >  If encoding is not supported returns ERROR.
> >
> >  Note --- not exists total corect conversion to ASCII, this function try
> >     convert chars those is _probably_ interpret-able in ASCII for
> >     others use ' '. But for example for all Czech characters it is
> >     sufficient ... hmm Chinese / JAP and other complicated langs have
> >     bad luck here :-(
> >
> >                         Karel
> Content-Description:
>
> [ application/x-gzip is not supported, skipping... ]
>
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: to_ascii()

From
Karel Zak
Date:
On Fri, 4 Aug 2000, Bruce Momjian wrote:

> I had to back out the patch. It only compiles with multi-byte enabled.

 Ooops, I forget... here it is again.

> > >  If encoding is not supported returns ERROR.

 and if multibyte not enabled too....


 Thanks.

                Karel

Attachment

Re: to_ascii()

From
Bruce Momjian
Date:
Applied.


>
> On Fri, 4 Aug 2000, Bruce Momjian wrote:
>
> > I had to back out the patch. It only compiles with multi-byte enabled.
>
>  Ooops, I forget... here it is again.
>
> > > >  If encoding is not supported returns ERROR.
>
>  and if multibyte not enabled too....
>
>
>  Thanks.
>
>                 Karel
Content-Description:

[ application/x-gzip is not supported, skipping... ]


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: to_ascii()

From
Bruce Momjian
Date:
I see the following warnings in a gcc compile with -Wall:

ascii.c: In function `to_ascii_encname':
ascii.c:41: warning: control reaches end of non-void function
ascii.c: In function `to_ascii_enc':
ascii.c:47: warning: control reaches end of non-void function
ascii.c: In function `to_ascii_default':
ascii.c:53: warning: control reaches end of non-void function


> Applied.
>
>
> >
> > On Fri, 4 Aug 2000, Bruce Momjian wrote:
> >
> > > I had to back out the patch. It only compiles with multi-byte enabled.
> >
> >  Ooops, I forget... here it is again.
> >
> > > > >  If encoding is not supported returns ERROR.
> >
> >  and if multibyte not enabled too....
> >
> >
> >  Thanks.
> >
> >                 Karel
> Content-Description:
>
> [ application/x-gzip is not supported, skipping... ]
>
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
>


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: to_ascii()

From
Karel Zak
Date:
On Sat, 5 Aug 2000, Bruce Momjian wrote:

> I see the following warnings in a gcc compile with -Wall:
>
> ascii.c: In function `to_ascii_encname':
> ascii.c:41: warning: control reaches end of non-void function
> ascii.c: In function `to_ascii_enc':
> ascii.c:47: warning: control reaches end of non-void function
> ascii.c: In function `to_ascii_default':
> ascii.c:53: warning: control reaches end of non-void function
>

 Grrr..... it's really bad day for me.

 Please, ignore this warning now. I will work on to_char() and this
I resolve too. It's pedantic warning from a gcc, these functions
always end with elog(ERROR..) and not with some return. But a gcc
don't knows it :-(

(or you can add "return (Datum) NULL;" to these three lines if you don't
want wait for me next patch).

 *Sorry* Bruce, I really didn't want kill your time....

                    Karel




Re: to_ascii()

From
Bruce Momjian
Date:
>
> On Sat, 5 Aug 2000, Bruce Momjian wrote:
>
> > I see the following warnings in a gcc compile with -Wall:
> >
> > ascii.c: In function `to_ascii_encname':
> > ascii.c:41: warning: control reaches end of non-void function
> > ascii.c: In function `to_ascii_enc':
> > ascii.c:47: warning: control reaches end of non-void function
> > ascii.c: In function `to_ascii_default':
> > ascii.c:53: warning: control reaches end of non-void function
> >
>
>  Grrr..... it's really bad day for me.
>
>  Please, ignore this warning now. I will work on to_char() and this
> I resolve too. It's pedantic warning from a gcc, these functions
> always end with elog(ERROR..) and not with some return. But a gcc
> don't knows it :-(
>
> (or you can add "return (Datum) NULL;" to these three lines if you don't
> want wait for me next patch).
>

No problem.  Just sent along when you are ready.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026