8 Temmuz 2011 Cuma

Google Go Programlama dili ile Bitwise operatörleri kullanarak Unicode code pointlerini byte dizisine çevirmek


package main

import (
"fmt"
)

func utf8(c int) {
switch {
case (c < 0x80):
putchar(c)

case (c < 0x800):
putchar(0xC0 | c>>6)
putchar(0x80 | c&0x3F)

case (c < 0x10000):
putchar(0xE0 | c>>12)
putchar(0x80 | c>>6&0x3F)
putchar(0x80 | c&0x3F)

case (c < 0x200000):
putchar(0xF0 | c>>18)
putchar(0x80 | c>>12&0x3F)
putchar(0x80 | c>>6&0x3F)
putchar(0x80 | c&0x3F)
}
}

func putchar(c int) {
fmt.Printf("%b ", c)
}

func main() {
utf8(187098)
}


Kaynak: http://czyborra.com/utf/

1 yorum:

  1. Las Vegas Hotel and Casino - JM Hub
    Find out the best and 천안 출장마사지 most comfortable 공주 출장안마 hotels 포항 출장안마 and casinos in 화성 출장안마 Las Vegas, NV. Click here to view room rates 수원 출장샵 & room service for more than 1000 hotels,

    YanıtlaSil