By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,447 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

Problem with file() and fgets()

P: n/a

Hi,

when reading lines from a text file using either of the functions file() or
fgets() all characters with ASCII codes greater than 127 get scrambled.

Using a hex editor I created a file containing a sequence of 128 bytes with
values from 128 up to 255.
After reading this file with file() or fgets() the string representing the
file content reads

196 197 199 201 209 214 220 225 224 226 228 227 229 231 233 232 234 235 237
236 238 239 241 243 242 244 246 245 250 249 251 252 221 176 162 163 167 128
182 223 174 169 129 180 168 130 198 216 131 177 190 132 165 181 143 133 189
188 134 170 186 135 230 248 191 161 172 136 159 137 144 171 187 138 160 192
195 213 145 166 173 139 179 178 140 185 247 215 255 141 142 164 208 240 222
254 253 183 146 147 148 194 202 193 203 200 205 206 207 204 211 212 149 210
218 219 217 158 150 151 175 152 153 154 184 155 156 157

instead of the desired sequence 128 to 255.

Characters with ASCII-Codes lower than 128 are read correctly.

Thanks for any help.

Jul 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.