You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/encoding.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,11 +51,35 @@ echo $newstr; // "Calendrier de l'avent façon Necta!" in US-ASCII encoding.
51
51
52
52
### Read sources
53
53
54
-
Currently, we only support loading from strings, as the examples above show. We will add additional ways to read sources in future versions. If you have any suggestions please let us know by opening an issue.
54
+
The `ConvertReadInterface` gives access to the the methods available to read strings into the converter. You can both read from a string variable or you can read from a file.
echo $newString; // the contents of the file in UTF-8 encoding (default).
66
+
```
55
67
56
68
### Write sources
57
69
58
-
The `ConvertWriteInterface` allows you to both convert the string to another string or a DTO. This allows you the flexibility to decide how you want to receive the data from the convert action.
70
+
The `ConvertWriteInterface` allows you to both convert the string to another string, file, or a DTO. This allows you the flexibility to decide how you want to receive the data from the convert action.
71
+
72
+
#### Write to file
73
+
74
+
```php
75
+
<?php
76
+
77
+
use StringEncoder\Encoder;
78
+
79
+
$str = "Calendrier de l'avent façon Necta!";
80
+
$encoder = new Encoder();
81
+
$encoder->convert()->fromString($str)->toFile('./path/to/file.txt'); // file.txt will be created and the contents will be put in it.
0 commit comments