Skip to content

Commit 50dfdca

Browse files
committed
Update SingleValueEncodingContainer.swift
1 parent bbc715c commit 50dfdca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sources/declarative/encodable/containers/SingleValueEncodingContainer.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,15 @@ extension ShadowEncoder.SingleValueContainer {
191191
mutating func encode(_ value: Decimal) throws {
192192
switch self._encoder.sink._withUnsafeGuaranteedRef({ $0.configuration.decimalStrategy }) {
193193
case .locale(let locale):
194-
var number = value
195-
let string = NSDecimalString(&number, locale)
194+
let nf = NumberFormatter()
195+
nf.numberStyle = .decimal
196+
nf.locale = locale
197+
let string = nf.string(from: NSDecimalNumber(decimal: value))
198+
199+
// This is crashing in Xcode 16b5
200+
// var number = value
201+
// let string = NSDecimalString(&number, locale)
202+
196203
try self.encode(string)
197204
case .custom(let closure):
198205
try closure(value, self._encoder)

0 commit comments

Comments
 (0)