커뮤니티 게시물

- 글자 수 계산시 codePointCount을 사용하여 글자수를 유니코드 기준으로 계산 하도록 수정
This commit is contained in:
Klaus 2024-06-17 23:02:20 +09:00
parent 6daaf22dc0
commit e87f19a8df
1 changed files with 3 additions and 2 deletions

View File

@ -39,11 +39,12 @@ data class SelectCommunityPostResponse @QueryProjection constructor(
if (existOrdered) {
content
} else {
if (content.length > 15) {
val length = content.codePointCount(0, content.length)
if (length > 15) {
val endIndex = content.offsetByCodePoints(0, 15)
content.substring(0, endIndex).plus("...")
} else {
val endIndex = content.offsetByCodePoints(0, content.length / 2)
val endIndex = content.offsetByCodePoints(0, length / 2)
content.substring(0, endIndex).plus("...")
}
}