Files
vgearenandClaude Sonnet 4.6 6b1f565d7d Initial release: macOS menu bar stock monitor
- A-shares, HK, and US stock real-time quotes (Sina / Tencent)
- Intraday minute charts (Tencent / Yahoo Finance)
- US extended-hours session indicator with price and change%
- Portfolio P&L tracking (cost price × shares)
- Sort by change%, color themes, launch at login
- File-based persistence with 10-snapshot rolling backup
- Universal binary (Apple Silicon + Intel)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 17:41:52 +08:00

24 lines
716 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
import CoreFoundation
enum StringDecoding {
/// 将 GBK/GB18030 编码的 Data 解码为 Swift String
static func decodeGBK(_ data: Data) -> String {
guard !data.isEmpty else { return "" }
if let enc = String.Encoding.gb18030,
let s = String(data: data, encoding: enc) { return s }
return String(data: data, encoding: .utf8) ?? ""
}
}
extension String.Encoding {
/// GB18030 编码(兼容 GBK / GB2312)
static var gb18030: String.Encoding? {
let cf = CFStringConvertEncodingToNSStringEncoding(
CFStringEncoding(CFStringEncodings.GB_18030_2000.rawValue)
)
return String.Encoding(rawValue: cf)
}
}