vendor/golang.org/x/text/unicode/norm/composition.go
changeset 251 1c52a0eeb952
parent 242 2a9ec03fe5a1
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
   405 	return 2 * JamoUTF8Len
   405 	return 2 * JamoUTF8Len
   406 }
   406 }
   407 
   407 
   408 // decomposeHangul algorithmically decomposes a Hangul rune into
   408 // decomposeHangul algorithmically decomposes a Hangul rune into
   409 // its Jamo components.
   409 // its Jamo components.
   410 // See http://unicode.org/reports/tr15/#Hangul for details on decomposing Hangul.
   410 // See https://unicode.org/reports/tr15/#Hangul for details on decomposing Hangul.
   411 func (rb *reorderBuffer) decomposeHangul(r rune) {
   411 func (rb *reorderBuffer) decomposeHangul(r rune) {
   412 	r -= hangulBase
   412 	r -= hangulBase
   413 	x := r % jamoTCount
   413 	x := r % jamoTCount
   414 	r /= jamoTCount
   414 	r /= jamoTCount
   415 	rb.appendRune(jamoLBase + r/jamoVCount)
   415 	rb.appendRune(jamoLBase + r/jamoVCount)
   418 		rb.appendRune(jamoTBase + x)
   418 		rb.appendRune(jamoTBase + x)
   419 	}
   419 	}
   420 }
   420 }
   421 
   421 
   422 // combineHangul algorithmically combines Jamo character components into Hangul.
   422 // combineHangul algorithmically combines Jamo character components into Hangul.
   423 // See http://unicode.org/reports/tr15/#Hangul for details on combining Hangul.
   423 // See https://unicode.org/reports/tr15/#Hangul for details on combining Hangul.
   424 func (rb *reorderBuffer) combineHangul(s, i, k int) {
   424 func (rb *reorderBuffer) combineHangul(s, i, k int) {
   425 	b := rb.rune[:]
   425 	b := rb.rune[:]
   426 	bn := rb.nrune
   426 	bn := rb.nrune
   427 	for ; i < bn; i++ {
   427 	for ; i < bn; i++ {
   428 		cccB := b[k-1].ccc
   428 		cccB := b[k-1].ccc
   459 
   459 
   460 // compose recombines the runes in the buffer.
   460 // compose recombines the runes in the buffer.
   461 // It should only be used to recompose a single segment, as it will not
   461 // It should only be used to recompose a single segment, as it will not
   462 // handle alternations between Hangul and non-Hangul characters correctly.
   462 // handle alternations between Hangul and non-Hangul characters correctly.
   463 func (rb *reorderBuffer) compose() {
   463 func (rb *reorderBuffer) compose() {
       
   464 	// Lazily load the map used by the combine func below, but do
       
   465 	// it outside of the loop.
       
   466 	recompMapOnce.Do(buildRecompMap)
       
   467 
   464 	// UAX #15, section X5 , including Corrigendum #5
   468 	// UAX #15, section X5 , including Corrigendum #5
   465 	// "In any character sequence beginning with starter S, a character C is
   469 	// "In any character sequence beginning with starter S, a character C is
   466 	//  blocked from S if and only if there is some character B between S
   470 	//  blocked from S if and only if there is some character B between S
   467 	//  and C, and either B is a starter or it has the same or higher
   471 	//  and C, and either B is a starter or it has the same or higher
   468 	//  combining class as C."
   472 	//  combining class as C."