[go-nuts] How to test for unicode property "Variation Selector"

2017-03-10 Thread JohnGB
I have some text that I'm processing which includes emoji. I'm trying to strip out all the emoji by using checking whether a rune fulfils unicode.IsSymbol(). This strips out the emoji, but it seems that some emoji include a unicode variation selector that is not stripped out. So I also need

[go-nuts] Should an input validation function correct the input?

2017-01-31 Thread JohnGB
In each of the handlers in an API I have, I first unmarshal the JSON request, and then validate the resulting struct. There are a few cases where I am able to pick up a correctable error in the validation code, but I'm not sure whether it's good practice to correct the error in the input data,

[go-nuts] Idiomatic way to reference custom error codes

2017-01-25 Thread JohnGB
I have an HTTP API written in Go, and to give more fine grained responses to the client app, we return our own error codes along with the standard HTTP status codes Along a similar line to what Twitter does with its error codes . The correct

Re: [go-nuts] Converting escaped unicode to utf8

2016-12-28 Thread JohnGB
My response should have read that it produces an error of "invalid character 'Ñ' looking for beginning of value". I got the responses from the two methods mixed up. On Monday, 26 December 2016 17:32:56 UTC+1, rog wrote: > > On 26 December 2016 at 07:23, JohnGB > &

Re: [go-nuts] Converting escaped unicode to utf8

2016-12-28 Thread JohnGB
y.golang.org/p/M-21sy_en5 > > On Monday, December 26, 2016 at 9:41:15 AM UTC-7, JohnGB wrote: >> >> Thanks Roger. That is a really elegant solution. >> >> On 26 December 2016 at 17:32, roger peppe wrote: >> >>> On 26 December 2016 at 07:23, JohnGB wro

Re: [go-nuts] Converting escaped unicode to utf8

2016-12-28 Thread JohnGB
ие' but it unescapes to 'MB> B5AB A>>1I5=85' instead. On Monday, 26 December 2016 17:32:56 UTC+1, rog wrote: > > On 26 December 2016 at 07:23, JohnGB > > wrote: > > It *should* have a JSON body, but in this particular case I can't be > sure

Re: [go-nuts] Converting escaped unicode to utf8

2016-12-28 Thread JohnGB
want something like this: > https://play.golang.org/p/M-21sy_en5 > > On Monday, December 26, 2016 at 9:41:15 AM UTC-7, JohnGB wrote: >> >> Thanks Roger. That is a really elegant solution. >> >> On 26 December 2016 at 17:32, roger peppe wrote: >> >>> On

Re: [go-nuts] Converting escaped unicode to utf8

2016-12-25 Thread JohnGB
y, 25 December 2016 06:14:22 UTC+1, Matt Harden wrote: > > If it has a JSON body, are you using encoding/json to parse / decode it? > That will handle the unescaping for you. > > On Sat, Dec 24, 2016 at 4:54 PM JohnGB > > wrote: > >> I have an application where I am p

[go-nuts] Converting escaped unicode to utf8

2016-12-24 Thread JohnGB
I have an application where I am processing a HTTP request with a JSON body. However, the JSON in the body has been unicode escaped, so instead of `wasn't`, I get `wasn\u0027t`. What is the simplest way to unescape this text back to utf8 encoded text. i.e. convert `wasn\u0027t` to `wasn't`.

Re: [go-nuts] How to generate a positive int64 from byte slice

2016-09-24 Thread JohnGB
y considering 63 bytes. On Saturday, 24 September 2016 02:32:24 UTC+2, Caleb Spare wrote: > > You'll probably want to use encoding/binary. > > But which 8 of the 32 bytes are you going to use? (or really, which 63 > bits?) > > -Caleb > > On Fri, Sep 23, 2016 a

[go-nuts] How to generate a positive int64 from byte slice

2016-09-23 Thread JohnGB
I have a byte slice 32 bytes long, and I would like to use it to generate a positive int64. Is there a standard way to do this, or do I need to write my own function (most likely using bit shifts)? The backstory is that I need to generate unique (low collision likelihood) integer IDs from emai