如果之前有人问过,我道歉 我发送一个包含大约750字节的长字符串,从iOS设备到蓝牙热敏打印机。但是,当打印出字符串时,打印机仅打印出CChar中大约160字节的部分上下文。我有点困惑为什么会发生这种情况,有人可以解释一下吗?
代码:
<div class="table-responsive">
<table id="basic-table" class="data-table table table-striped nowrap table-hover" cellspacing="0" width="100%">
<thead>
<tr>
<th>{{'Plate'|translate}}</th>
<th>{{'Driver Name'|translate}}</th>
<th>{{'Start Time'|translate}}</th>
<th>{{'Starting Address'|translate}}</th>
<th>{{'End Time'|translate}}</th>
<th>{{'Ending Address'|translate}}</th>
<th>{{'Work Duration'|translate}}</th>
<th>{{'Distance'|translate}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of workDataReportList">
<td>{{item.Name}}</td>
<td>{{item.DriverName}}</td>
<td>{{item.StartTime | date:'dd.MM.yy hh:mm'}}</td>
<td>{{item.StartAddress}}</td>
<td>{{item.EndTime | date:'dd.MM.yy hh:mm'}}</td>
<td>{{item.EndAddress}}</td>
<td>{{item.RunningTime}}</td>
<td>{{item.Km | distance}}</td>
</tr>
</tbody>
</table>
</div>
</div>
在writeValue函数中
let cfEnc = CFStringEncodings.GB_18030_2000
let enc = CFStringConvertEncodingToNSStringEncoding(CFStringEncoding(cfEnc.rawValue))
let ccc = "The franchise began in 1977 with the release of the film Star Wars
(subtitled Episode IV: A New Hope in 1981[2][3]), which became a worldwide pop
culture phenomenon. It was followed by the successful sequels The Empire
Strikes Back (1980) and Return of the Jedi (1983); these three films constitute
the original Star Wars trilogy. A prequel trilogy was released between 1999 and
2005, which received mixed reactions. A sequel trilogy began in 2015 with the
release of Star Wars: The Force Awakens. All seven films were nominated for
Academy Awards (with wins going to the first two films) and have been
commercial successes, with a combined box office revenue of $7.471 billion,[4]
making Star Wars the third highest-grossing film series.[5] Spin-off films
include Star Wars: The Clone Wars (2008) and Rogue One (2016), which is the
first in an upcoming series of anthology films.\n\nThe series has spawned an
extensive media franchise—the Star Wars expanded universe—including books,
television series, computer and video games, and comic books, resulting in
significant development of the series's fictional universe. Star Wars also
holds a Guinness World Records title for the \"Most successful film
merchandising franchise. In 2015, the total value of the Star Wars franchise
was estimated at USD $41.9 billion,[6] making Star Wars the second highest-
grossing media franchise of all time.\n\nIn 2012, The Walt Disney Company
acquired Lucasfilm for $4.06 billion and earned the distribution rights to all
subsequent Star Wars films, beginning with the release of The Force Awakens in
2015.[7] The former distributor, 20th Century Fox, retains the physical
distribution rights to the first two Star Wars trilogies, owning permanent
rights for the original 1977 film and holding the rights to Episodes I–III, V,
and VI until May 2020.[8][9] Walt Disney Studios owns digital distribution
rights to all the Star Wars films, excluding A New Hope."
print(ccc.lengthOfBytes(using: String.Encoding(rawValue: enc))) //count number is 164
if let data = ccc.data(using: String.Encoding(rawValue: enc)) {
self.writeValue(data)
}
我是否必须切断字符串才能使其正常工作?