Question: How can I detect if a user holds their finger down on an onscreen object for 1 second ?

Thanks,

Martin

Answer: 
You should not simply discard the BOM unless you're 100% sure that the stream will: (a) always be UTF-8, and (b) always have a UTF-8 BOM.

The reasons:

1. In UTF-8, a BOM is *optional* - so if the service quits sending it at some future point you'll be throwing away the first three characters of your response instead.
2. The whole purpose of the BOM is to identify unambiguously the type of UTF stream being interpreted UTF-8? -16? or -32?, and also to indicate the 'endian-ness' (byte order) of the encoded information. If you just throw it away you're assuming that you're always getting UTF-8; this may not be a very good assumption.
3. Not all BOMs are 3-bytes long, only the UTF-8 one is three bytes. UTF-16 is two bytes, and UTF-32 is four bytes. So if the service switches to a wider UTF encoding in the future, your code will break.

I think a more appropriate way to handle this would be something like:

```
/* Detect the encoding, then convert from detected encoding to ASCII */
$enc = mb_detect_encoding($data);
$data = mb_convert_encoding($data, "ASCII", $enc);

```
To remove it from the beginning of the string (only):

```
$data = preg_replace('/^%EF%BB%BF/', '', $data);

```