Charles is not a common Norwegian name from that period, but if you are confident about the birth town being Halden, and not Oslo, and the birth being in October 1839, then this would be a good candidate:
Carl Christian Hansen, born 12 Oct 1839, bap. 25 Mar 1840, son of Skibscaptain (ship-captain) Hans Martin Hansen and wife Anne Mathilde born Svindt, according to this baptism protocol. There are no other candidates born in October in Halden at least.
The Svindt family came from Denmark, and the ancestors of Anne Mathilde way back can be found on Geni.
Here are the parents of Carl Christian in the census of 1865. Only the daughter Elise is present, age 23, at that time. This record places the family at Håøen farm in Strømmen parish, on the other side of Viken from Halden, so Carl Christian's father gave up his sailing in his old age, and bought a farm. According to the farm book for Strømmen (Eier, Sigfred L.: ''Strømms historie''. 1951.), skipper Hans Martin Hansen from Drøbak bought a farm at Håøen in 1865 for 2,200 dlr. His farming days were limited, though, as in 1875, his widow sold the farm on for 1,675 dlr. This is a significant sum, and Carl Cristian should have been a heir in this. I do not find the probate records on line for this period, though.
The entry for Hans Martin Hansen in the 1865 census states that he was born in Drøbak in 1801. We can find a good candidate in the birth registry there; Hans Martin, son of Carl Hansen and Johanne Andreasdatter, baptised 12 Dec 1801. At first I ruled this candidate out, since with the father's name being Carl, he should be using the name Hans Martin Carlsen. However, if we look at the census for 1801, where we find the couple before Hans Martin is born, they have a son age 2, and he is named Morthen Hanssen, not Carlsen, so it appears they were for some reason naming their children with Hansen as a family name and not a patronymical.
Hans Martin's father is listed as Carl Christian Hansen, so Charlie was apparently named after his grandfather. The 1801 record lists him as a soldier, age 25. So Charlies military service in the US appears to have been a family tradition.
Now, going back to the parents of Carl Christian Hansen, age 25 in 1801, so born in 1776, we find this baptism on S. 19. e Trin: (= 13 Oct 1776): "Morten Hansen's twins from south Rustad, the 1st named Wilhelm, ... the 2nd named Carl Christian, ...", so Hans Martin was not the first to break the patronymical tradition. There is actually a forum discussion on exactly this case (in norwegian).
The farm book for South Rustad in Vestby, only mentions that Morten Hansen bought the farm in 1770, and that he had the sons Vilhelm and Carl Christian while living there. He sold the farm again shortly after, and moved to Tannum. But following the story to Tannum farm in Vestby, a more complete story is told. The Tannum farm that Morten obtained in 1776 was the family farm. It had been passed to Morten's half-brother Hans Hansen in 1771, but in 1776 Hans moved to the city for a job as inspector and sold the farm to his brother for 2700 rdl.
About Morten the farm book states that he was born in 1751 and died on 23 Oct 1783, aged only 32½ years old. He was married to Hanna Johanne Holmsdatter, a widow after Bastian Strøm. Their children were: 1) Hans Johan (b. 1775, d. 1780), 2) Wilhelm (b. -77), 3) Carl Christian (b. -77), 4) Ove Hendrik (b. -78, d.sm.yr), 5) Hans (b. -79, d. -80, 6) Ove Hendrik (b. 14/6 -79, d. -80), 7) Hansine Johanne (b. -80, d.sm.yr), 8) Karen Weis (b. 28/4 -82, d. 18/8 -88), so a lot of dead siblings. Also, in -81, Hanna's daughter from her first marriage, Kristine (Stine) Johanne Strøm died, leaving the twin brothers with a signifiicant heritage. But Morten himself died in 1783, leaving the twins and their (still living) sister Karen with an impressive list of heirlooms. However, Hanna marries again shortly after to an Andreas Christensen, who sold of the property and apparently mismanaged the funds of Hanna and her children, leaving them with little left. The children is said to have been raised with their grandmother at Bråte.
So, the brothers Hans and Morten Hansen were sons of the former owner of Tannum farm, Hans Hansen, born in 1721 and still alive in 1776. He was married twice, #1 to Margrethe Nilsdatter Weydahl (1726 - 1749), #2 to Karen Weis. Hans had 2 children in his first marriage, and 4 in his second, but only Hans and Morten lived to adulthood. Hans Hansen Senior was, again, the son of the former user at Tannum, who was named (no surpises here) Hans Hansen, born in 1696 and died at Tannum on 25/8 1746. The probate after him is extensive and lists a lot of silver and tin items with inscriptions. This Hans was married to Valborg Amudsdatter, and they had two daughters that lived and married. It appears from the farm book that took over the farm in 1708, aged only 16 years old. He was not born at Tannum, but was the son of Hans Hansen Bråte, who has a profile on Geni.