FAQ
hi,all:

in unicode/utf16 EncodeRune:

func EncodeRune(r rune) (r1, r2 rune) {

     if r < surrSelf || r > maxRune || IsSurrogate(r) {

         return replacementChar, replacementChar

     }

     r -= surrSelf

     return surr1 + (r>>10)&0x3ff, surr2 + r&0x3ff

}


can remove || IsSurrogate(r) ???

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Dec 15, 2013 at 11:38 am
    Interestingly it looks like you can, all the tests still pass.

    Please raise an issue, golang.org/issue/new
    On Sun, Dec 15, 2013 at 10:34 PM, 产学红 wrote:
    hi,all:

    in unicode/utf16 EncodeRune:

    func EncodeRune(r rune) (r1, r2 rune) {

    if r < surrSelf || r > maxRune || IsSurrogate(r) {

    return replacementChar, replacementChar

    }

    r -= surrSelf

    return surr1 + (r>>10)&0x3ff, surr2 + r&0x3ff

    }


    can remove || IsSurrogate(r) ???

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Minux at Dec 15, 2013 at 5:06 pm

    On Dec 15, 2013 6:34 AM, "产学红" wrote:
    hi,all:

    in unicode/utf16 EncodeRune:
    func EncodeRune(r rune) (r1, r2 rune) {
    if r < surrSelf || r > maxRune || IsSurrogate(r) {

    return replacementChar, replacementChar

    }

    r -= surrSelf

    return surr1 + (r>>10)&0x3ff, surr2 + r&0x3ff

    }
    can remove || IsSurrogate(r) ???
    it could be removed because the first condition contains it. as i said in
    the reply to your another related topic, please send a CL.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Dec 15, 2013 at 10:09 pm
    If you do remove IsSurrogate from that check then there is 0 coverage
    of IsSurrogate.

    If you want to propose a CL to make this change, please ensure that
    you add additional testing of IsSurrogate.
    On Mon, Dec 16, 2013 at 4:06 AM, minux wrote:
    On Dec 15, 2013 6:34 AM, "产学红" wrote:

    hi,all:

    in unicode/utf16 EncodeRune:
    func EncodeRune(r rune) (r1, r2 rune) {
    if r < surrSelf || r > maxRune || IsSurrogate(r) {

    return replacementChar, replacementChar

    }

    r -= surrSelf

    return surr1 + (r>>10)&0x3ff, surr2 + r&0x3ff

    }
    can remove || IsSurrogate(r) ???
    it could be removed because the first condition contains it. as i said in
    the reply to your another related topic, please send a CL.

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Minux at Dec 15, 2013 at 10:14 pm

    On Sun, Dec 15, 2013 at 5:09 PM, Dave Cheney wrote:

    If you do remove IsSurrogate from that check then there is 0 coverage
    of IsSurrogate.
    as the first condition (r < surrSelf) strictly includes IsSurrogate(r), I
    don't think
    that qualifies as test coverage of IsSurrogate.

    Anyway, I think we do need to test IsSurrogate if it deemed not simple
    enough
    to be not tested.
    If you want to propose a CL to make this change, please ensure that
    you add additional testing of IsSurrogate.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dave Cheney at Dec 15, 2013 at 11:32 pm

    On Mon, Dec 16, 2013 at 9:14 AM, minux wrote:
    On Sun, Dec 15, 2013 at 5:09 PM, Dave Cheney wrote:

    If you do remove IsSurrogate from that check then there is 0 coverage
    of IsSurrogate.
    as the first condition (r < surrSelf) strictly includes IsSurrogate(r), I
    don't think
    that qualifies as test coverage of IsSurrogate.

    Anyway, I think we do need to test IsSurrogate if it deemed not simple
    enough
    to be not tested.
    https://codereview.appspot.com/42570043

    If you want to propose a CL to make this change, please ensure that
    you add additional testing of IsSurrogate.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 15, '13 at 11:34a
activeDec 15, '13 at 11:32p
posts6
users3
websitegolang.org

3 users in discussion

Dave Cheney: 3 posts Minux: 2 posts 产学红: 1 post

People

Translate

site design / logo © 2021 Grokbase