Re: [racket-users] Re: custom byte encoders?

2021-04-23 Thread Matthew Flatt
A new custom port sounds like the right idea. The `reencode-input-port`
and ``reencode-output-port` implementations in
"collects/racket/port.rkt" are tied to byte converters, but they should
be the right idea and could be generalized to other conversion
functions. You might have to copy them for now, but you could propose
changes so that future Racket versions would have the right
abstraction.

Matthew

At Fri, 23 Apr 2021 00:20:43 -0700 (PDT), "je...@lisp.sh" wrote:
> The more I read in section 4.5.4 the more it dawns on me that what I'm 
> after may not be possible without (a) a custom patched version of Racket 
> and/or (b) a custom patched version of libiconv. An alternative -- I think 
> -- would be a custom input port, but even that might require (a) and/or (b) 
> above. Naturally, I'd prefer not to have to have a private variant of 
> Racket, and I'd rather not roll my own encoder in C. If there's no other 
> way, I'll do it. But maybe I'm overlooking something simpler.
> 
> On Friday, April 23, 2021 at 7:01:45 AM UTC+2 je...@lisp.sh wrote:
> 
> > Is it possible to make your own byte encoder? Section 4.5.4 of the 
> > reference talks about them and describes the handful of built-in ones. I 
> > don't see a way of making my own byte encoders, though. I'd like to have my 
> > own way of validating bytes and performing replacements, similar to what is 
> > done with the "UTF-8-permissive" encoder (for example, certain junk 
> > characters get replaced by #\uFFFD), but I'd like to do a bit more than 
> > that. For example, I'd like replace some exotic but otherwise valid UTF-8 
> > characters with #\uFFFD. It seems that the only way to do that is to write 
> > my own custom input (or output) port, with the validation/replacement logic 
> > contained within the custom port's peek/read-bytes/write-bytes procedures. 
> > Or perhaps I overlooking something?
> >
> > Jesse
> >
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email 
> to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/2a29be0f-382d-44ee-b691-91c6b527f
> c48n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20210423065343.db%40sirmail.smtps.cs.utah.edu.


[racket-users] Re: custom byte encoders?

2021-04-23 Thread je...@lisp.sh
The more I read in section 4.5.4 the more it dawns on me that what I'm 
after may not be possible without (a) a custom patched version of Racket 
and/or (b) a custom patched version of libiconv. An alternative -- I think 
-- would be a custom input port, but even that might require (a) and/or (b) 
above. Naturally, I'd prefer not to have to have a private variant of 
Racket, and I'd rather not roll my own encoder in C. If there's no other 
way, I'll do it. But maybe I'm overlooking something simpler.

On Friday, April 23, 2021 at 7:01:45 AM UTC+2 je...@lisp.sh wrote:

> Is it possible to make your own byte encoder? Section 4.5.4 of the 
> reference talks about them and describes the handful of built-in ones. I 
> don't see a way of making my own byte encoders, though. I'd like to have my 
> own way of validating bytes and performing replacements, similar to what is 
> done with the "UTF-8-permissive" encoder (for example, certain junk 
> characters get replaced by #\uFFFD), but I'd like to do a bit more than 
> that. For example, I'd like replace some exotic but otherwise valid UTF-8 
> characters with #\uFFFD. It seems that the only way to do that is to write 
> my own custom input (or output) port, with the validation/replacement logic 
> contained within the custom port's peek/read-bytes/write-bytes procedures. 
> Or perhaps I overlooking something?
>
> Jesse
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2a29be0f-382d-44ee-b691-91c6b527fc48n%40googlegroups.com.