An earthquake with a preliminary magnitude of 4.9 shook Taiwan on Wednesday, but there were no immediate reports of casualties or damage.