212 "return the chunk-separation character" |
212 "return the chunk-separation character" |
213 |
213 |
214 ^ ChunkSeparator |
214 ^ ChunkSeparator |
215 ! ! |
215 ! ! |
216 |
216 |
|
217 |
217 !Stream methodsFor:'Compatibility-Dolphin'! |
218 !Stream methodsFor:'Compatibility-Dolphin'! |
218 |
219 |
219 display:someObject |
220 display:someObject |
220 "dolphin compatibility" |
221 "dolphin compatibility" |
221 |
222 |
222 "/ someObject printOn:self. |
223 "/ someObject printOn:self. |
223 self nextPutAll: someObject asString. |
224 self nextPutAll: someObject asString. |
224 ! ! |
225 ! ! |
225 |
226 |
226 !Stream methodsFor:'Compatibility-ST80'! |
|
227 |
|
228 nextLongPut:aNumber |
|
229 <resource: #obsolete> |
|
230 |
|
231 "for ST-80 compatibility: |
|
232 Write the argument, aNumber as a long (four bytes). |
|
233 The most significant byte is sent first." |
|
234 |
|
235 ^ self nextPutInt32:aNumber MSB:true |
|
236 |
|
237 "Modified: 10.1.1996 / 19:38:54 / cg" |
|
238 ! |
|
239 |
|
240 nextPutWord:aNumber |
|
241 <resource: #obsolete> |
|
242 |
|
243 "write the argument, aNumber as a signed short (two bytes); |
|
244 write msb-first for compatibility with other smalltalks. |
|
245 The receiver must support writing of binary bytes. |
|
246 I dont know if it should be named nextPutWord: or nextWordPut:; |
|
247 one of them will vanish ..." |
|
248 |
|
249 ^ self nextPutInt16:aNumber MSB:true |
|
250 ! |
|
251 |
|
252 nextTwoBytesPut: anInteger |
|
253 <resource: #obsolete> |
|
254 "Write anInteger as the next two bytes of the |
|
255 receiver stream." |
|
256 |
|
257 self obsoleteMethodWarning:'use #nextPutShort:MSB:'. |
|
258 |
|
259 self |
|
260 nextPutByte: (anInteger bitAnd: 255); |
|
261 nextPutByte: ((anInteger bitShift: -8) bitAnd: 255) |
|
262 |
|
263 "Created: / 21-06-2006 / 19:42:10 / fm" |
|
264 ! |
|
265 |
|
266 nextWordPut:aNumber |
|
267 <resource: #obsolete> |
|
268 |
|
269 "for ST-80 compatibility: |
|
270 Write the argument, aNumber as a short (two bytes). |
|
271 The most significant byte is sent first." |
|
272 |
|
273 ^ self nextPutInt16:aNumber MSB:true |
|
274 |
|
275 "Modified: 10.1.1996 / 19:39:19 / cg" |
|
276 ! ! |
|
277 |
227 |
278 |
228 |
279 |
229 |
280 !Stream methodsFor:'accessing'! |
230 !Stream methodsFor:'accessing'! |
281 |
231 |
1222 " |
1134 " |
1223 |
1135 |
1224 "Modified: / 14.1.1998 / 15:40:41 / cg" |
1136 "Modified: / 14.1.1998 / 15:40:41 / cg" |
1225 ! |
1137 ! |
1226 |
1138 |
1227 nextInt32Net |
|
1228 "return a signed long (4 bytes) in network byte order from the stream. |
|
1229 The receiver must support reading of binary bytes. |
|
1230 Network byte order is MSB-first per definition" |
|
1231 |
|
1232 ^ self nextInt32MSB:true |
|
1233 |
|
1234 "Created: 10.1.1996 / 19:49:28 / cg" |
|
1235 ! |
|
1236 |
|
1237 nextInt64LSB |
|
1238 "return a signed longlong (also called hyper) (8 bytes) in LSB-first order from the stream. |
|
1239 The receiver must support reading of binary bytes." |
|
1240 |
|
1241 ^ self nextInt64MSB:false |
|
1242 ! |
|
1243 |
|
1244 nextInt64MSB |
|
1245 "return a signed longlong (also called hyper) (8 bytes) in MSB-first order from the stream. |
|
1246 The receiver must support reading of binary bytes." |
|
1247 |
|
1248 ^ self nextInt64MSB:true |
|
1249 ! |
|
1250 |
|
1251 nextInt64MSB:msbFlag |
1139 nextInt64MSB:msbFlag |
1252 "return a signed longlong (also called hyper) (8 bytes) from the stream. |
1140 "return a signed longlong (also called hyper) (8 bytes) from the stream. |
1253 The receiver must support reading of binary bytes. |
1141 The receiver must support reading of binary bytes. |
1254 |
1142 |
1255 The msbFlag argument controls if the integer is to be read with |
1143 The msbFlag argument controls if the integer is to be read with |
1416 s := #[ 16r01 16r02 16r03 16r04 16r05 16r06 16r07 16r08 16r09 ] readStream. |
1289 s := #[ 16r01 16r02 16r03 16r04 16r05 16r06 16r07 16r08 16r09 ] readStream. |
1417 (s nextUnsigned:9 MSB:false) hexPrintString. |
1290 (s nextUnsigned:9 MSB:false) hexPrintString. |
1418 " |
1291 " |
1419 ! |
1292 ! |
1420 |
1293 |
1421 nextUnsignedHyperMSB:msbFlag |
1294 nextUnsignedInt16MSB:msbFlag |
1422 "return an unsigned hyper (8 bytes) from the stream. |
1295 "return an unsigned short (2 bytes) from the stream. |
1423 The receiver must support reading of binary bytes. |
1296 The receiver must support reading of binary bytes. |
1424 |
1297 |
1425 The msbFlag argument controls if the integer is to be read with |
1298 The msbFlag argument controls if the integer is to be read with |
1426 most-significant-byte-first (true) or least-first (false). |
1299 most-significant-byte-first (true) or least-first (false). |
1427 This interface is provided to allow talking to external programs, |
1300 This interface is provided to allow talking to external programs, |
1428 where it's known that the byte order is some definite one. |
1301 where it's known that the byte order is some definite one. |
1429 If you don't care (i.e. talk to other smalltalks) or you can control the |
1302 If you don't care (i.e. talk to other smalltalks) or you can control the |
1430 order, please use the corresponding xxxNet methods, which use a standard |
1303 order, please use the corresponding xxxNet methods, which use a standard |
1431 network byte order." |
1304 network byte order." |
1432 |
1305 |
1433 ^ self nextUnsignedInt64MSB:msbFlag |
1306 |b1 b2 uval "{ Class: SmallInteger }"| |
1434 |
|
1435 " |
|
1436 |bytes s| |
|
1437 |
|
1438 bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]. |
|
1439 s := bytes readStream. |
|
1440 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1441 s reset. |
|
1442 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1443 |
|
1444 bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00]. |
|
1445 s := bytes readStream. |
|
1446 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1447 s reset. |
|
1448 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1449 |
|
1450 bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0]. |
|
1451 s := bytes readStream. |
|
1452 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1453 s reset. |
|
1454 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1455 |
|
1456 bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10]. |
|
1457 s := bytes readStream. |
|
1458 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1459 s reset. |
|
1460 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1461 " |
|
1462 |
|
1463 "Modified: / 14.1.1998 / 15:40:41 / cg" |
|
1464 ! |
|
1465 |
|
1466 nextUnsignedInt16LSB |
|
1467 "return an unsigned short (2 bytes) in LSB-first order from the stream. |
|
1468 The receiver must support reading of binary bytes." |
|
1469 |
|
1470 ^ self nextUnsignedInt16MSB:false |
|
1471 ! |
|
1472 |
|
1473 nextUnsignedInt16MSB |
|
1474 "return an unsigned short (2 bytes) in MSB-first order from the stream. |
|
1475 The receiver must support reading of binary bytes." |
|
1476 |
|
1477 ^ self nextUnsignedInt16MSB:true |
|
1478 ! |
|
1479 |
|
1480 nextUnsignedInt16MSB:msbFlag |
|
1481 "return an unsigned short (2 bytes) from the stream. |
|
1482 The receiver must support reading of binary bytes. |
|
1483 |
|
1484 The msbFlag argument controls if the integer is to be read with |
|
1485 most-significant-byte-first (true) or least-first (false). |
|
1486 This interface is provided to allow talking to external programs, |
|
1487 where it's known that the byte order is some definite one. |
|
1488 If you don't care (i.e. talk to other smalltalks) or you can control the |
|
1489 order, please use the corresponding xxxNet methods, which use a standard |
|
1490 network byte order." |
|
1491 |
|
1492 |b1 b2 bH bL| |
|
1493 |
1307 |
1494 b1 := self nextByte. |
1308 b1 := self nextByte. |
1495 b2 := self nextByte. |
1309 b2 := self nextByte. |
1496 |
1310 |
1497 msbFlag ifTrue:[ |
1311 msbFlag ifTrue:[ |
1498 bH := b1. |
1312 "most significant first" |
1499 bL := b2. |
1313 uval := b1 bitShift:8. |
|
1314 uval := uval bitOr:b2. |
1500 ] ifFalse:[ |
1315 ] ifFalse:[ |
1501 bL := b1. |
1316 "least significant first" |
1502 bH := b2. |
1317 uval := b2 bitShift:8. |
1503 ]. |
1318 uval := uval bitOr:b1. |
1504 ^ (bH bitShift:8) bitOr:bL |
1319 ]. |
|
1320 |
|
1321 ^ uval |
1505 |
1322 |
1506 " |
1323 " |
1507 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt16MSB:true) hexPrintString |
1324 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt16MSB:true) hexPrintString |
1508 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt16MSB:false) hexPrintString |
1325 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt16MSB:false) hexPrintString |
1509 " |
1326 " |
1510 |
1327 |
1511 "Modified: 11.7.1996 / 10:07:20 / cg" |
1328 "Modified: 11.7.1996 / 10:07:20 / cg" |
1512 ! |
|
1513 |
|
1514 nextUnsignedInt16Net |
|
1515 "return an unsigned short (2 bytes) in network byte order from the stream. |
|
1516 The receiver must support reading of binary bytes. |
|
1517 Network byte order is MSB-first per definition" |
|
1518 |
|
1519 ^ self nextUnsignedInt16MSB:true |
|
1520 |
|
1521 "Created: 10.1.1996 / 19:50:02 / cg" |
|
1522 ! |
1329 ! |
1523 |
1330 |
1524 nextUnsignedInt24MSB:msbFlag |
1331 nextUnsignedInt24MSB:msbFlag |
1525 "return an unsigned 3 byte integer from the stream. |
1332 "return an unsigned 3 byte integer from the stream. |
1526 The receiver must support reading of binary bytes. |
1333 The receiver must support reading of binary bytes. |
1554 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:true) hexPrintString |
1361 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:true) hexPrintString |
1555 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:false) hexPrintString |
1362 ((ReadStream on:#[16r10 16r20 16r30]) nextUnsignedInt24MSB:false) hexPrintString |
1556 " |
1363 " |
1557 ! |
1364 ! |
1558 |
1365 |
1559 nextUnsignedInt32LSB |
|
1560 "return an unsigned long (4 bytes) in LSB-first order from the stream. |
|
1561 The receiver must support reading of binary bytes." |
|
1562 |
|
1563 ^ self nextUnsignedInt32MSB:false |
|
1564 ! |
|
1565 |
|
1566 nextUnsignedInt32MSB |
|
1567 "return an unsigned long (4 bytes) in MSB-first order from the stream. |
|
1568 The receiver must support reading of binary bytes." |
|
1569 |
|
1570 ^ self nextUnsignedInt32MSB:true |
|
1571 ! |
|
1572 |
|
1573 nextUnsignedInt32MSB:msbFlag |
1366 nextUnsignedInt32MSB:msbFlag |
1574 "return an unsigned long (4 bytes) from the stream. |
1367 "return an unsigned long (4 bytes) from the stream. |
1575 The receiver must support reading of binary bytes. |
1368 The receiver must support reading of binary bytes. |
1576 |
1369 |
1577 The msbFlag argument controls if the integer is to be read with |
1370 The msbFlag argument controls if the integer is to be read with |
1580 where it's known that the byte order is some definite one. |
1373 where it's known that the byte order is some definite one. |
1581 If you don't care (i.e. talk to other smalltalks) or you can control the |
1374 If you don't care (i.e. talk to other smalltalks) or you can control the |
1582 order, please use the corresponding xxxNet methods, which use a standard |
1375 order, please use the corresponding xxxNet methods, which use a standard |
1583 network byte order." |
1376 network byte order." |
1584 |
1377 |
1585 |b1 b2 b3 b4 val| |
1378 |b1 b2 b3 b4 uval "{ Class: SmallInteger }" val| |
1586 |
1379 |
1587 b1 := self nextByte. |
1380 b1 := self nextByte. |
1588 b2 := self nextByte. |
1381 b2 := self nextByte. |
1589 b3 := self nextByte. |
1382 b3 := self nextByte. |
1590 b4 := self nextByte. |
1383 b4 := self nextByte. |
1591 |
1384 |
1592 msbFlag ifTrue:[ |
1385 msbFlag ifTrue:[ |
1593 val := b1. |
1386 "most significant first" |
1594 val := (val bitShift:8) bitOr:b2. |
1387 uval := (b1 bitShift:8) bitOr:b2. |
1595 val := (val bitShift:8) bitOr:b3. |
1388 uval := (uval bitShift:8) bitOr:b3. |
1596 val := (val * 256) + b4. |
1389 val := (uval bitShift:8) bitOr:b4. |
1597 ^ val |
1390 ] ifFalse:[ |
1598 ]. |
1391 "least significant first" |
1599 val := b4. |
1392 uval := (b4 bitShift:8) bitOr:b3. |
1600 val := (val bitShift:8) bitOr:b3. |
1393 uval := (uval bitShift:8) bitOr:b2. |
1601 val := (val bitShift:8) bitOr:b2. |
1394 val := (uval bitShift:8) bitOr:b1. |
1602 val := (val * 256) + b1. |
1395 ]. |
|
1396 |
1603 ^ val |
1397 ^ val |
1604 |
|
1605 "Modified: 11.7.1996 / 10:07:13 / cg" |
|
1606 ! |
|
1607 |
|
1608 nextUnsignedInt32Net |
|
1609 "return an unsigned long (4 bytes) in network byte order from the stream. |
|
1610 The receiver must support reading of binary bytes. |
|
1611 Network byte order is MSB-first per definition" |
|
1612 |
|
1613 ^ self nextUnsignedInt32MSB:true |
|
1614 |
|
1615 "Created: 10.1.1996 / 19:49:02 / cg" |
|
1616 "Modified: 10.1.1996 / 19:49:50 / cg" |
|
1617 ! |
|
1618 |
|
1619 nextUnsignedInt64LSB |
|
1620 "return an unsigned longlong (also called hyper) (8 bytes) in LSB-first order from the stream. |
|
1621 The receiver must support reading of binary bytes." |
|
1622 |
|
1623 ^ self nextUnsignedInt64MSB:false |
|
1624 ! |
|
1625 |
|
1626 nextUnsignedInt64MSB |
|
1627 "return an unsigned longlong (also called hyper) (8 bytes) in MSB-first order from the stream. |
|
1628 The receiver must support reading of binary bytes." |
|
1629 |
|
1630 ^ self nextUnsignedInt64MSB:true |
|
1631 ! |
1398 ! |
1632 |
1399 |
1633 nextUnsignedInt64MSB:msbFlag |
1400 nextUnsignedInt64MSB:msbFlag |
1634 "return an unsigned longlong (also called hyper) (8 bytes) from the stream. |
1401 "return an unsigned longlong (also called hyper) (8 bytes) from the stream. |
1635 The receiver must support reading of binary bytes. |
1402 The receiver must support reading of binary bytes. |
1689 s reset. |
1456 s reset. |
1690 Transcript showCR:(s nextUnsignedInt64MSB:false) hexPrintString. |
1457 Transcript showCR:(s nextUnsignedInt64MSB:false) hexPrintString. |
1691 " |
1458 " |
1692 |
1459 |
1693 "Modified: / 14.1.1998 / 15:40:41 / cg" |
1460 "Modified: / 14.1.1998 / 15:40:41 / cg" |
|
1461 ! ! |
|
1462 |
|
1463 !Stream methodsFor:'non homogenous reading - aliases'! |
|
1464 |
|
1465 nextInt16LSB |
|
1466 "return a signed short (2 bytes) in LSB-first order from the stream. |
|
1467 The receiver must support reading of binary bytes." |
|
1468 |
|
1469 ^ self nextInt16MSB:false |
|
1470 ! |
|
1471 |
|
1472 nextInt16MSB |
|
1473 "return a signed short (2 bytes) in MSB-first order from the stream. |
|
1474 The receiver must support reading of binary bytes." |
|
1475 |
|
1476 ^ self nextInt16MSB:true |
|
1477 ! |
|
1478 |
|
1479 nextInt16Net |
|
1480 "return a signed short (2 bytes) in network byte order from the stream. |
|
1481 The receiver must support reading of binary bytes. |
|
1482 Network byte order is MSB-first per definition" |
|
1483 |
|
1484 ^ self nextInt16MSB:true |
|
1485 |
|
1486 "Created: 10.1.1996 / 19:49:41 / cg" |
|
1487 ! |
|
1488 |
|
1489 nextInt32LSB |
|
1490 "return a signed long (4 bytes) in LSB-first order from the stream. |
|
1491 The receiver must support reading of binary bytes." |
|
1492 |
|
1493 ^ self nextInt32MSB:false |
|
1494 ! |
|
1495 |
|
1496 nextInt32MSB |
|
1497 "return a signed long (4 bytes) in MSB-first order from the stream. |
|
1498 The receiver must support reading of binary bytes." |
|
1499 |
|
1500 ^ self nextInt32MSB:true |
|
1501 ! |
|
1502 |
|
1503 nextInt32Net |
|
1504 "return a signed long (4 bytes) in network byte order from the stream. |
|
1505 The receiver must support reading of binary bytes. |
|
1506 Network byte order is MSB-first per definition" |
|
1507 |
|
1508 ^ self nextInt32MSB:true |
|
1509 |
|
1510 "Created: 10.1.1996 / 19:49:28 / cg" |
|
1511 ! |
|
1512 |
|
1513 nextInt64LSB |
|
1514 "return a signed longlong (also called hyper) (8 bytes) in LSB-first order from the stream. |
|
1515 The receiver must support reading of binary bytes." |
|
1516 |
|
1517 ^ self nextInt64MSB:false |
|
1518 ! |
|
1519 |
|
1520 nextInt64MSB |
|
1521 "return a signed longlong (also called hyper) (8 bytes) in MSB-first order from the stream. |
|
1522 The receiver must support reading of binary bytes." |
|
1523 |
|
1524 ^ self nextInt64MSB:true |
|
1525 ! |
|
1526 |
|
1527 nextInt64Net |
|
1528 "return a signed longlong (also called hyper) (8 bytes) in network byte order from the stream. |
|
1529 The receiver must support reading of binary bytes. |
|
1530 Network byte order is MSB-first per definition" |
|
1531 |
|
1532 ^ self nextInt64MSB:true |
|
1533 ! |
|
1534 |
|
1535 nextNumber:numBytes |
|
1536 "Return the next n bytes as a positive Integer; |
|
1537 bytes are taken msb-first." |
|
1538 |
|
1539 ^ self nextUnsigned:numBytes MSB:true |
|
1540 ! |
|
1541 |
|
1542 nextUnsignedInt16LSB |
|
1543 "return an unsigned short (2 bytes) in LSB-first order from the stream. |
|
1544 The receiver must support reading of binary bytes." |
|
1545 |
|
1546 ^ self nextUnsignedInt16MSB:false |
|
1547 ! |
|
1548 |
|
1549 nextUnsignedInt16MSB |
|
1550 "return an unsigned short (2 bytes) in MSB-first order from the stream. |
|
1551 The receiver must support reading of binary bytes." |
|
1552 |
|
1553 ^ self nextUnsignedInt16MSB:true |
|
1554 ! |
|
1555 |
|
1556 nextUnsignedInt16Net |
|
1557 "return an unsigned short (2 bytes) in network byte order from the stream. |
|
1558 The receiver must support reading of binary bytes. |
|
1559 Network byte order is MSB-first per definition" |
|
1560 |
|
1561 ^ self nextUnsignedInt16MSB:true |
|
1562 |
|
1563 "Created: 10.1.1996 / 19:50:02 / cg" |
|
1564 ! |
|
1565 |
|
1566 nextUnsignedInt32LSB |
|
1567 "return an unsigned long (4 bytes) in LSB-first order from the stream. |
|
1568 The receiver must support reading of binary bytes." |
|
1569 |
|
1570 ^ self nextUnsignedInt32MSB:false |
|
1571 ! |
|
1572 |
|
1573 nextUnsignedInt32MSB |
|
1574 "return an unsigned long (4 bytes) in MSB-first order from the stream. |
|
1575 The receiver must support reading of binary bytes." |
|
1576 |
|
1577 ^ self nextUnsignedInt32MSB:true |
|
1578 ! |
|
1579 |
|
1580 nextUnsignedInt32Net |
|
1581 "return an unsigned long (4 bytes) in network byte order from the stream. |
|
1582 The receiver must support reading of binary bytes. |
|
1583 Network byte order is MSB-first per definition" |
|
1584 |
|
1585 ^ self nextUnsignedInt32MSB:true |
|
1586 |
|
1587 "Created: 10.1.1996 / 19:49:02 / cg" |
|
1588 "Modified: 10.1.1996 / 19:49:50 / cg" |
|
1589 ! |
|
1590 |
|
1591 nextUnsignedInt64LSB |
|
1592 "return an unsigned longlong (also called hyper) (8 bytes) in LSB-first order from the stream. |
|
1593 The receiver must support reading of binary bytes." |
|
1594 |
|
1595 ^ self nextUnsignedInt64MSB:false |
|
1596 ! |
|
1597 |
|
1598 nextUnsignedInt64MSB |
|
1599 "return an unsigned longlong (also called hyper) (8 bytes) in MSB-first order from the stream. |
|
1600 The receiver must support reading of binary bytes." |
|
1601 |
|
1602 ^ self nextUnsignedInt64MSB:true |
1694 ! |
1603 ! |
1695 |
1604 |
1696 nextUnsignedInt64Net |
1605 nextUnsignedInt64Net |
1697 "return an unsigned longlong (also called hyper) (8 bytes) in network byte order from the stream. |
1606 "return an unsigned longlong (also called hyper) (8 bytes) in network byte order from the stream. |
1698 The receiver must support reading of binary bytes. |
1607 The receiver must support reading of binary bytes. |
1833 Network byte order is MSB per definition" |
1742 Network byte order is MSB per definition" |
1834 |
1743 |
1835 ^ self nextInt16MSB:true |
1744 ^ self nextInt16MSB:true |
1836 |
1745 |
1837 "Created: 10.1.1996 / 19:49:41 / cg" |
1746 "Created: 10.1.1996 / 19:49:41 / cg" |
|
1747 ! |
|
1748 |
|
1749 nextUnsignedHyperMSB:msbFlag |
|
1750 <resource: #obsolete> |
|
1751 "return an unsigned hyper (8 bytes) from the stream. |
|
1752 The receiver must support reading of binary bytes. |
|
1753 |
|
1754 The msbFlag argument controls if the integer is to be read with |
|
1755 most-significant-byte-first (true) or least-first (false). |
|
1756 This interface is provided to allow talking to external programs, |
|
1757 where it's known that the byte order is some definite one. |
|
1758 If you don't care (i.e. talk to other smalltalks) or you can control the |
|
1759 order, please use the corresponding xxxNet methods, which use a standard |
|
1760 network byte order." |
|
1761 |
|
1762 ^ self nextUnsignedInt64MSB:msbFlag |
|
1763 |
|
1764 " |
|
1765 |bytes s| |
|
1766 |
|
1767 bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]. |
|
1768 s := bytes readStream. |
|
1769 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1770 s reset. |
|
1771 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1772 |
|
1773 bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00]. |
|
1774 s := bytes readStream. |
|
1775 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1776 s reset. |
|
1777 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1778 |
|
1779 bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0]. |
|
1780 s := bytes readStream. |
|
1781 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1782 s reset. |
|
1783 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1784 |
|
1785 bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10]. |
|
1786 s := bytes readStream. |
|
1787 Transcript showCR:(s nextUnsignedHyperMSB:true) hexPrintString. |
|
1788 s reset. |
|
1789 Transcript showCR:(s nextUnsignedHyperMSB:false) hexPrintString. |
|
1790 " |
|
1791 |
|
1792 "Modified: / 14.1.1998 / 15:40:41 / cg" |
1838 ! |
1793 ! |
1839 |
1794 |
1840 nextUnsignedLongMSB:msbFlag |
1795 nextUnsignedLongMSB:msbFlag |
1841 <resource: #obsolete> |
1796 <resource: #obsolete> |
1842 "return an unsigned long (4 bytes) from the stream. |
1797 "return an unsigned long (4 bytes) from the stream. |
2449 nextPutUtf16:aCharacter |
2411 nextPutUtf16:aCharacter |
2450 "append my UTF-16 representation to the argument, aStream. |
2412 "append my UTF-16 representation to the argument, aStream. |
2451 Notice: this writes characters - not bytes. |
2413 Notice: this writes characters - not bytes. |
2452 The underlying stream must be a stream which can deal with characters, |
2414 The underlying stream must be a stream which can deal with characters, |
2453 eg. OrderedCollectionStream, TwoByteCharacterStream, etc. |
2415 eg. OrderedCollectionStream, TwoByteCharacterStream, etc. |
2454 Also notice, that characters above 16rFFFF are escaped according UTF16 sepcifications." |
2416 Also notice, that characters above 16rFFFF are escaped according UTF16 specifications." |
2455 |
2417 |
2456 |codePoint "{Class: SmallInteger}"| |
2418 |codePoint "{Class: SmallInteger}"| |
2457 |
2419 |
2458 codePoint := aCharacter codePoint. |
2420 codePoint := aCharacter codePoint. |
2459 (codePoint <= 16rD7FF |
2421 (codePoint <= 16rD7FF |
2476 nextPutUtf16:$B; |
2438 nextPutUtf16:$B; |
2477 nextPutUtf16:$Ä; |
2439 nextPutUtf16:$Ä; |
2478 nextPutUtf16:(Character codePoint:16r10CCCC) |
2440 nextPutUtf16:(Character codePoint:16r10CCCC) |
2479 yourself) contents |
2441 yourself) contents |
2480 " |
2442 " |
|
2443 ! |
|
2444 |
|
2445 nextPutUtf16Bytes:aCharacter MSB:msb |
|
2446 "append my UTF-16 representation to the argument, aStream. |
|
2447 UTF-16 can encode only characters with code points between 0 to 16r10FFFF. |
|
2448 The underlying stream must support writing of bytes." |
|
2449 |
|
2450 |codePoint| |
|
2451 |
|
2452 codePoint := aCharacter codePoint. |
|
2453 (codePoint <= 16rD7FF |
|
2454 or:[ codePoint >= 16rE000 and:[ codePoint <= 16rFFFF ] ]) |
|
2455 ifTrue:[ self nextPutInt16:codePoint MSB:msb. ] |
|
2456 ifFalse:[ |
|
2457 codePoint <= 16r10FFFF ifTrue:[ |
|
2458 |highBits lowBits| |
|
2459 |
|
2460 codePoint := codePoint - 16r100000. |
|
2461 highBits := codePoint bitShift:-10. |
|
2462 lowBits := codePoint bitAnd:16r3FF. |
|
2463 self nextPutInt16:highBits + 16rD800 MSB:msb. |
|
2464 self nextPutInt16:lowBits + 16rDC00 MSB:msb. |
|
2465 ] ifFalse:[ |
|
2466 EncodingError raiseWith:aCharacter |
|
2467 errorString:'Character cannot be encoded as UTF-16'. |
|
2468 ] |
|
2469 ]. |
|
2470 |
|
2471 " |
|
2472 (#[] writeStream |
|
2473 nextPutUtf16:$B MSB:true; |
|
2474 nextPutUtf16:$Ä MSB:true; |
|
2475 nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true; |
|
2476 contents) |
|
2477 |
|
2478 (FileStream newTemporary |
|
2479 nextPutUtf16:$B MSB:false; |
|
2480 nextPutUtf16:$Ä MSB:false; |
|
2481 nextPutUtf16:(Character codePoint:16r10CCCC) MSB:false; |
|
2482 reset; |
|
2483 binary; |
|
2484 contents)" |
2481 ! |
2485 ! |
2482 |
2486 |
2483 nextPutUtf8:aCharacter |
2487 nextPutUtf8:aCharacter |
2484 "append my UTF-8 representation to the argument, aStream. |
2488 "append my UTF-8 representation to the argument, aStream. |
2485 The underlying stream must be a stream which can deal with characters. |
2489 The underlying stream must be a stream which can deal with characters. |