Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

UTF-8 Unicode Safe Golang Byte Size WordWrap

License

NotificationsYou must be signed in to change notification settings

donatj/wordwrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report CardCIGoDoc

UTF-8 Safe Word Wrapping for Go based on number of bytes.

This is a word wrap library that doesn’tbreak UTF-8 runesandoperates on number of bytes rather than runes. It’s preference is to break on a unicode space character, but will break long words if necessary. This is particularly useful for breaking up unicode messages on protocols where message size is limited by bytes.

Samples

English:

fmt.Println(wordwrap.WrapString(`If any earl, baron, or other person that holds lands directly of the Crown, for military service, shall die, and at his death his heir shall be of full age and owe a 'relief', the heir shall have his inheritance on payment of the ancient scale of 'relief'.`,60))

Becomes:

If any earl, baron, or other person that holds lands         // 53 bytesdirectly of the Crown, for military service, shall die, and  // 60 bytesat his death his heir shall be of full age and owe a         // 53 bytes'relief', the heir shall have his inheritance on payment of  // 60 bytesthe ancient scale of 'relief'.                               // 30 bytes

Japanese:

fmt.Println(wordwrap.WrapString(`クラウンの直接土地を保持している任意の伯爵、男爵、または他の人は、兵役のために、死ぬ、と彼の死で彼の後継者は成年であることと「救済」を借りなければならない場合は、相続人は、支払いの彼の継承をもたなければなりません「救済」の古代規模の。`,60))

Becomes:

クラウンの直接土地を保持している任意の伯  // 60 bytes爵、男爵、または他の人は、兵役のために、  // 60 bytes死ぬ、と彼の死で彼の後継者は成年であるこ  // 60 bytesとと「救済」を借りなければならない場合は  // 60 bytes、相続人は、支払いの彼の継承をもたなけれ  // 60 bytesばなりません「救済」の古代規模の。        // 51 bytes

Korean:

fmt.Println(wordwrap.WrapString(`크라운 의 직접 토지 를 보유하고 있는 백작 , 남작 , 또는 다른 사람이 군 복무 를 위해 죽을 것이요, 그의 죽음 에 그의 후계자 가 전체 연령 하고' 구호 '을 빚을 해야 하는 경우, 상속인 이 지불 에 대한 자신의 상속을 가져야한다 ' 구호 ' 의 고대 규모의 `,60))

Becomes:

크라운직접토지보유하고있는백작// 59 bytes,남작 ,또는다른사람이복무위해// 57 bytes죽을것이요,그의죽음그의후계자// 57 bytes전체연령하고'구호 '을빚을해야하는// 55 bytes경우,상속인지불대한자신의상속을// 60 bytes가져야한다 '구호 '고대규모의// 47 bytes

[8]ページ先頭

©2009-2025 Movatter.jp