الفرق بين المراجعتين ل"Kotlin/kotlin.text/codePointCount"
< Kotlin | kotlin.text
اذهب إلى التنقل
اذهب إلى البحث
(أنشأ الصفحة ب'<noinclude>{{DISPLAYTITLE: الدالة <code>text.codePointCount()</code> في لغة Kotlin}}</noinclude> تعيد الدالة <code>codePointCount()</code> ك...') |
|||
سطر 1: | سطر 1: | ||
<noinclude>{{DISPLAYTITLE: الدالة <code>text.codePointCount()</code> في لغة Kotlin}}</noinclude> | <noinclude>{{DISPLAYTITLE: الدالة <code>text.codePointCount()</code> في لغة Kotlin}}</noinclude> | ||
− | تعيد الدالة <code>codePointCount()</code> | + | تعيد الدالة <code>codePointCount()</code> عدد أكواد اليونيكود (Unicode code point) في المجال المُحدّد من النص. |
==البنية العامة== | ==البنية العامة== | ||
<syntaxhighlight lang="kotlin"> | <syntaxhighlight lang="kotlin"> | ||
− | inline fun String. | + | inline fun String.codePointCount( |
− | + | beginIndex: Int, | |
+ | endIndex: Int | ||
+ | ): Int | ||
</syntaxhighlight>يُلاحَظ وجود الكلمة المفتاحية <code>inline</code> للدلالة على أن هذه الدالة مباشرة، وللمزيد من التفاصيل راجع <nowiki/>[[Kotlin/inline functions|توثيق الدوال المباشرة (inline functions)]]. | </syntaxhighlight>يُلاحَظ وجود الكلمة المفتاحية <code>inline</code> للدلالة على أن هذه الدالة مباشرة، وللمزيد من التفاصيل راجع <nowiki/>[[Kotlin/inline functions|توثيق الدوال المباشرة (inline functions)]]. | ||
سطر 11: | سطر 13: | ||
==أمثلة== | ==أمثلة== | ||
===استخدام الدالة <code>()codePointCount</code> مع سلسلة نصية=== | ===استخدام الدالة <code>()codePointCount</code> مع سلسلة نصية=== | ||
− | تعرِّف الشيفرة الآتية سلسلة نصية باسم <code>str</code>، ثمَّ تستدعي الدالة <code>()codePointCount</code> | + | تعرِّف الشيفرة الآتية سلسلة نصية باسم <code>str</code>، ثمَّ تستدعي الدالة <code>()codePointCount</code> عبرها مع تمرير عددين كوسيطين، <nowiki/>ثمَّ تطبع الناتج:<syntaxhighlight lang="kotlin"> |
fun main(args: Array<String>) { | fun main(args: Array<String>) { | ||
val str = "hsoub Academy" | val str = "hsoub Academy" | ||
− | println(str. | + | println(str.codePointCount(2,8)) // => 6 |
− | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
سطر 22: | سطر 23: | ||
* <code>[[Kotlin/kotlin.text/codePointAt|codePointAt()]]</code>: تعيد كود اليونيكود (Unicode code point) للحرف الموجود في الفهرس المُحدّد. | * <code>[[Kotlin/kotlin.text/codePointAt|codePointAt()]]</code>: تعيد كود اليونيكود (Unicode code point) للحرف الموجود في الفهرس المُحدّد. | ||
− | * <code>[[Kotlin/kotlin.text/ | + | * <code>[[Kotlin/kotlin.text/codePointBefore|codePointBefore()]]</code>: تعيد كود اليونيكود (Unicode code point) للحرف الموجود قبل الفهرس المُحدّد. |
* <code>[[Kotlin/kotlin.text/asSequence|asSequence()]]</code>: تنشئ كائنًا من الصنف <code>Sequence</code> والذي يُغلّف سلسلة الحروف التي استُدعيت عبرها، لأجل استعمالها في الحلقات التكرارية. | * <code>[[Kotlin/kotlin.text/asSequence|asSequence()]]</code>: تنشئ كائنًا من الصنف <code>Sequence</code> والذي يُغلّف سلسلة الحروف التي استُدعيت عبرها، لأجل استعمالها في الحلقات التكرارية. | ||
==مصادر== | ==مصادر== | ||
− | *[http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/code-point- | + | *[http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/code-point-count.html الدالة text.codePointCount() في التوثيق الرسميّ للمكتبة القياسيّة في لغة Kotlin.] |
[[تصنيف:Kotlin]] | [[تصنيف:Kotlin]] | ||
[[تصنيف:Kotlin Functions]] | [[تصنيف:Kotlin Functions]] |
مراجعة 11:49، 8 يوليو 2018
تعيد الدالة codePointCount()
عدد أكواد اليونيكود (Unicode code point) في المجال المُحدّد من النص.
البنية العامة
inline fun String.codePointCount(
beginIndex: Int,
endIndex: Int
): Int
يُلاحَظ وجود الكلمة المفتاحية inline
للدلالة على أن هذه الدالة مباشرة، وللمزيد من التفاصيل راجع توثيق الدوال المباشرة (inline functions).
القيم المعادة
عدد من النوع Int
.
أمثلة
استخدام الدالة ()codePointCount
مع سلسلة نصية
تعرِّف الشيفرة الآتية سلسلة نصية باسم str
، ثمَّ تستدعي الدالة ()codePointCount
عبرها مع تمرير عددين كوسيطين، ثمَّ تطبع الناتج:
fun main(args: Array<String>) {
val str = "hsoub Academy"
println(str.codePointCount(2,8)) // => 6
}
انظر أيضًا
codePointAt()
: تعيد كود اليونيكود (Unicode code point) للحرف الموجود في الفهرس المُحدّد.
codePointBefore()
: تعيد كود اليونيكود (Unicode code point) للحرف الموجود قبل الفهرس المُحدّد.asSequence()
: تنشئ كائنًا من الصنفSequence
والذي يُغلّف سلسلة الحروف التي استُدعيت عبرها، لأجل استعمالها في الحلقات التكرارية.