2010-10-19 17 views
11

Programlama bağlamında "offset" ne anlama geliyor?Programlama bağlamında "offset" ne anlama geliyor?

Başlangıçta mı yoksa bir mesafede mi demek?

String.offsetByCodePoints(int index, int codePointOffset) yöntemi ne yapar? Yöntem belgelerinde "eşlenmemiş vekiller" ne anlama geliyor? JavaDoc'u göre

+2

http://en.wikipedia.org/wiki/Offset_%28computer_science%29 ... kullanım örneğidir –

+1

http: // tr .wikipedia.org/wiki/Mapping_of_Unicode_characters # – dsetton

+0

Sorunuzun ikinci kısmı için surrogates Teşekkürler şimdi temiz – skystar7

cevap

2

,

String.offsetByCodePoints(int index, int codePointOffset) 

{@code codePointOffset} kodu nokta {@code indeksi} kayıktır bu nesne içinde dizinini döndürür. İşte

Sorunuzun ilk bölümü için

int num = 0; 
num = "Test_String".offsetByCodePoints(0, 2); //num is 2 
num = "Test_String".offsetByCodePoints(3, 2); //num is 5 
num = "Test_String".offsetByCodePoints(9, 5); //Throws an exception since offset goes out-of-bounds 
+0

'num =" Test_String ".offsetByCodePoints (3, 2); // num, benim için 6' 5 baskıdır –

+0

Üzgünüm, "kapalı 1" yazım hatası. Şimdi sabit. –

+0

Şimdiden teşekkürler – skystar7