What makes the engine weak (sp)? How many miles? Have you checked the compression? A lot of times people have what can be a decent functioning engine but opt to spend significantly to replace it only to find it has maybe five more nearly unnoticeable horsepower.
In one sense, yes a Ranger 2.3 engine should fit. BUT, there are all kinds of subtle differences regarding mounting accessories etc.. And wanting to retain the harness and carb only complicate the matter. Most any Ranger engine you will find will be EFI. So, whatever the differences are to deal with; round ports, D ports, dual plugs, ignition, pulley type etc. need to be considered (and, no I'm not the guy to tell you). I'd:
1. Determine what is wrong (if anything) with the current 2.3.
2. If that engine is too worn then consider rebuilding it.
2. If that is not your choice then you have a lot of research to do. In one sense the "right" 2.3 should be a simple bolt in. On the other hand a "wrong" 2.3 might have you chasing odd parts. I'd guess that a junk yard engine will cost you in the $300-$500 range and a rebuilt in the $1,200 to $2,000 range.
Lastly will you be doing the work yourself..., or paying someone to do it.?