alibaba / alibaba/HandyJSON

系统设置为阿拉伯语时数字会被转换成阿拉伯语

Open
#448 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4.3k
Forks
677
PR merge metrics
No merged PRs in 30d

Description

formatter.string(from: num) 系统阿拉伯语数字会被转成阿拉伯语("١٦٢١٢٤٨٩٣٢٠٧٣")
![596caffd178dc3ae18bbc1df407d63bb](https://user-images.githubusercontent.com/25809097/129126108-ff650ca2-bcc9-4e11-8399-1e8b76b35183.png)
目前我暂时修改了一下凑合着用吧
static func _transform(from object: Any) -> String? {
switch object {
case let str as String:
return str
case let num as NSNumber:
// Boolean Type Inside
if NSStringFromClass(type(of: num)) == "__NSCFBoolean" {
if num.boolValue {
return "true"
} else {
return "false"
}
}
/// 系统设置为阿拉伯语时 formatter.string(from: num)会转换成阿拉伯语( "١٦٢١٢٤٨٩٣٢٠٧٣")
return String.init(format: "%@", num) //formatter.string(from: num)
case _ as NSNull:
return nil
default:
return "\(object)"
}
}

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue points to static _transform(from:) and its NSNumber branch, where formatter.string(from:) produces Arabic-Indic digits under Arabic system settings. Reproduce the behavior with an Arabic locale and numeric input, then locate the relevant serialization tests and verify the output and existing boolean/null handling. No test file is named, so the test entry point must be found first.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.